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 | Static Private Attributes
PhiSymmetryCalibration Class Reference

#include <PhiSymmetryCalibration.h>

Inheritance diagram for PhiSymmetryCalibration:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 Called at each event. More...
 
virtual void beginJob ()
 Called at beginning of job. More...
 
virtual void endJob ()
 Called at end of job. More...
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endRun (edm::Run &, const edm::EventSetup &)
 
 PhiSymmetryCalibration (const edm::ParameterSet &iConfig)
 Constructor. More...
 
void setUp (const edm::EventSetup &setup)
 
 ~PhiSymmetryCalibration ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void getKfactors ()
 

Private Attributes

double ap_
 
double b_
 
std::vector< DetIdbarrelCells
 
std::string barrelHits_
 
EcalGeomPhiSymHelper e_
 
std::vector< TH1F * > e_spectrum_b_histos
 
std::vector< TH1F * > e_spectrum_e_histos
 
std::string ecalHitsProducer_
 
double eCut_barl_
 
std::vector< DetIdendcapCells
 
std::string endcapHits_
 
float epsilon_M_barl [kBarlRings][kBarlWedges][kSides]
 
float epsilon_M_endc [kEndcWedgesX][kEndcWedgesY][kSides]
 
double esumMean_barl_ [kBarlRings]
 
double esumMean_endc_ [kEndcEtaRings]
 
std::vector< TH1F * > et_spectrum_b_histos
 
std::vector< TH1F * > et_spectrum_e_histos
 
double etsum_barl_ [kBarlRings][kBarlWedges][kSides]
 
double etsum_barl_miscal_ [kNMiscalBinsEB][kBarlRings]
 
double etsum_endc_ [kEndcWedgesX][kEndcWedgesX][kSides]
 
double etsum_endc_miscal_ [kNMiscalBinsEE][kEndcEtaRings]
 
double etsum_endc_uncorr [kEndcWedgesX][kEndcWedgesX][kSides]
 
double etsumMean_barl_ [kBarlRings]
 
double etsumMean_endc_ [kEndcEtaRings]
 
int eventSet_
 
int eventsinlb_
 
int eventsinrun_
 
bool isfirstpass_
 
double k_barl_ [kBarlRings]
 
double k_endc_ [kEndcEtaRings]
 
double miscalEB_ [kNMiscalBinsEB]
 
double miscalEE_ [kNMiscalBinsEE]
 
int nevents_
 
double newCalibs_barl [kBarlRings][kBarlWedges][kSides]
 
double newCalibs_endc [kEndcWedgesX][kEndcWedgesX][kSides]
 
unsigned int nhits_barl_ [kBarlRings][kBarlWedges][kSides]
 
unsigned int nhits_endc_ [kEndcWedgesX][kEndcWedgesX][kSides]
 
std::string oldcalibfile_
 
EcalIntercalibConstants oldCalibs_
 the old calibration constants (when reiterating, the last ones derived) More...
 
double oldCalibs_barl [kBarlRings][kBarlWedges][kSides]
 
double oldCalibs_endc [kEndcWedgesX][kEndcWedgesY][kSides]
 
float phi_endc [kMaxEndciPhi][kEndcEtaRings]
 
float rawconst_barl [kBarlRings][kBarlWedges][kSides]
 
float rawconst_endc [kEndcWedgesX][kEndcWedgesX][kSides]
 
bool reiteration_
 
bool spectra
 
int statusThreshold_
 threshold in channel status beyond which channel is marked bad More...
 

Static Private Attributes

static const int kMaxEndciPhi = 360
 
static const float kMiscalRangeEB = .05
 
static const float kMiscalRangeEE = .10
 
static const int kNMiscalBinsEB = 21
 
static const int kNMiscalBinsEE = 41
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- 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::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 35 of file PhiSymmetryCalibration.h.

Constructor & Destructor Documentation

PhiSymmetryCalibration::PhiSymmetryCalibration ( const edm::ParameterSet iConfig)

Constructor.

Definition at line 59 of file PhiSymmetryCalibration.cc.

References e_spectrum_b_histos, e_spectrum_e_histos, et_spectrum_b_histos, et_spectrum_e_histos, eventsinlb_, eventsinrun_, isfirstpass_, kBarlRings, kEndcEtaRings, nevents_, and spectra.

59  :
60 
61  ecalHitsProducer_(iConfig.getParameter<std::string>("ecalRecHitsProducer")),
62  barrelHits_( iConfig.getParameter< std::string > ("barrelHitCollection")),
63  endcapHits_( iConfig.getParameter< std::string > ("endcapHitCollection")),
64  eCut_barl_( iConfig.getParameter< double > ("eCut_barrel") ),
65  ap_( iConfig.getParameter<double> ("ap") ),
66  b_( iConfig.getParameter<double> ("b") ),
67  eventSet_( iConfig.getParameter< int > ("eventSet") ),
68  statusThreshold_(iConfig.getUntrackedParameter<int>("statusThreshold",3)),
69  reiteration_(iConfig.getUntrackedParameter< bool > ("reiteration",false)),
70  oldcalibfile_(iConfig.getUntrackedParameter<std::string>("oldcalibfile",
71  "EcalintercalibConstants.xml"))
72 {
73 
74 
75  isfirstpass_=true;
76 
81 
82  spectra=true;
83 
84  nevents_=0;
85  eventsinrun_=0;
86  eventsinlb_=0;
87 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static const int kBarlRings
std::vector< TH1F * > et_spectrum_b_histos
std::vector< TH1F * > e_spectrum_b_histos
static const int kEndcEtaRings
std::vector< TH1F * > et_spectrum_e_histos
int statusThreshold_
threshold in channel status beyond which channel is marked bad
std::vector< TH1F * > e_spectrum_e_histos
PhiSymmetryCalibration::~PhiSymmetryCalibration ( )

Destructor.

Definition at line 93 of file PhiSymmetryCalibration.cc.

References e_spectrum_b_histos, e_spectrum_e_histos, et_spectrum_b_histos, et_spectrum_e_histos, i, kBarlRings, and kEndcEtaRings.

94 {
95 
96 
97  for(Int_t i=0;i<kBarlRings;i++){
98  delete et_spectrum_b_histos[i];
99  delete e_spectrum_b_histos[i];
100 
101  }
102  for(Int_t i=0;i<kEndcEtaRings;i++){
103  delete et_spectrum_e_histos[i];
104  delete e_spectrum_e_histos[i];
105  }
106 
107 
108 }
int i
Definition: DBlmapReader.cc:9
static const int kBarlRings
std::vector< TH1F * > et_spectrum_b_histos
std::vector< TH1F * > e_spectrum_b_histos
static const int kEndcEtaRings
std::vector< TH1F * > et_spectrum_e_histos
std::vector< TH1F * > e_spectrum_e_histos

Member Function Documentation

void PhiSymmetryCalibration::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
virtual

Called at each event.

Implements edm::EDAnalyzer.

Definition at line 273 of file PhiSymmetryCalibration.cc.

References funct::abs(), ap_, b_, barrelHits_, EcalGeomPhiSymHelper::cellPos_, alignCSCRings::e, e_, e_spectrum_b_histos, e_spectrum_e_histos, DetId::Ecal, EcalBarrel, EcalEndcap, ecalHitsProducer_, eCut_barl_, endcapHits_, EcalGeomPhiSymHelper::endcapRing_, et_spectrum_b_histos, et_spectrum_e_histos, PV3DBase< T, PVType, FrameType >::eta(), eta(), EcalGeomPhiSymHelper::etaBoundary_, etsum_barl_, etsum_barl_miscal_, etsum_endc_, etsum_endc_miscal_, eventSet_, eventsinlb_, eventsinrun_, HcalObjRepresent::Fill(), edm::EventSetup::get(), EcalGeomPhiSymHelper::goodCell_barl, EcalGeomPhiSymHelper::goodCell_endc, EBDetId::ieta(), EBDetId::iphi(), isfirstpass_, EEDetId::ix(), EEDetId::iy(), kEndcEtaRings, kNMiscalBinsEB, kNMiscalBinsEE, miscalEB_, miscalEE_, nevents_, nhits_barl_, nhits_endc_, EcalGeomPhiSymHelper::nRing_, oldCalibs_, reiteration_, relativeConstraints::ring, setUp(), spectra, and EEDetId::zside().

274 {
275  using namespace edm;
276  using namespace std;
277 
278  if (isfirstpass_) {
279  setUp(setup);
280  isfirstpass_=false;
281  }
282 
283 
284  Handle<EBRecHitCollection> barrelRecHitsHandle;
285  Handle<EERecHitCollection> endcapRecHitsHandle;
286 
287  event.getByLabel(ecalHitsProducer_,barrelHits_,barrelRecHitsHandle);
288  if (!barrelRecHitsHandle.isValid()) {
289  LogError("") << "[PhiSymmetryCalibration] Error! Can't get product!" << std::endl;
290  }
291 
292  event.getByLabel(ecalHitsProducer_,endcapHits_,endcapRecHitsHandle);
293  if (!endcapRecHitsHandle.isValid()) {
294  LogError("") << "[PhiSymmetryCalibration] Error! Can't get product!" << std::endl;
295  }
296 
297 
298  // get the ecal geometry
299  edm::ESHandle<CaloGeometry> geoHandle;
300  setup.get<CaloGeometryRecord>().get(geoHandle);
301  const CaloSubdetectorGeometry *barrelGeometry =
302  geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
303  const CaloSubdetectorGeometry *endcapGeometry =
304  geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
305 
306  bool pass=false;
307  // select interesting EcalRecHits (barrel)
309  for (itb=barrelRecHitsHandle->begin(); itb!=barrelRecHitsHandle->end(); itb++) {
310  EBDetId hit = EBDetId(itb->id());
311  float eta = barrelGeometry->getGeometry(hit)->getPosition().eta();
312  float et = itb->energy()/cosh(eta);
313  float e = itb->energy();
314 
315 
316 
317  // if iterating, correct by the previous calib constants found,
318  // which are supplied in the form of correction
319  if (reiteration_) {
320  et= et * oldCalibs_[hit];
321  e = e * oldCalibs_[hit];
322  }
323 
324  float et_thr = eCut_barl_/cosh(eta) + 1.;
325 
326  int sign = hit.ieta()>0 ? 1 : 0;
327 
328  if (e > eCut_barl_ && et < et_thr && e_.goodCell_barl[abs(hit.ieta())-1][hit.iphi()-1][sign]) {
329  etsum_barl_[abs(hit.ieta())-1][hit.iphi()-1][sign] += et;
330  nhits_barl_[abs(hit.ieta())-1][hit.iphi()-1][sign] ++;
331  pass =true;
332  }//if energy
333 
334  if (eventSet_==1) {
335  // apply a miscalibration to all crystals and increment the
336  // ET sum, combined for all crystals
337  for (int imiscal=0; imiscal<kNMiscalBinsEB; imiscal++) {
338  if (miscalEB_[imiscal]*e > eCut_barl_&& miscalEB_[imiscal]*et < et_thr && e_.goodCell_barl[abs(hit.ieta())-1][hit.iphi()-1][sign]) {
339  etsum_barl_miscal_[imiscal][abs(hit.ieta())-1] += miscalEB_[imiscal]*et;
340  }
341  }
342 
343  // spectra stuff
344  if(spectra && hit.ieta()>0) //POSITIVE!!!
345  // if(spectra && hit.ieta()<0) //NEGATIVE!!!
346  {
347  et_spectrum_b_histos[abs(hit.ieta())-1]->Fill(et*1000.);
348  e_spectrum_b_histos[abs(hit.ieta())-1]->Fill(e*1000.);
349  }//if spectra
350 
351  }//if eventSet_==1
352  }//for barl
353 
354 
355  // select interesting EcalRecHits (endcaps)
357  for (ite=endcapRecHitsHandle->begin(); ite!=endcapRecHitsHandle->end(); ite++) {
358  EEDetId hit = EEDetId(ite->id());
359  float eta = abs(endcapGeometry->getGeometry(hit)->getPosition().eta());
360  //float phi = endcapGeometry->getGeometry(hit)->getPosition().phi();
361 
362  float et = ite->energy()/cosh(eta);
363  float e = ite->energy();
364 
365  // if iterating, multiply by the previous correction factor
366  if (reiteration_) {
367  et= et * oldCalibs_[hit];
368  e = e * oldCalibs_[hit];
369  }
370 
371  int sign = hit.zside()>0 ? 1 : 0;
372 
373 
374  // changes of eCut_endc_ -> variable linearthr
375  // e_cut = ap + eta_ring*b
376 
377  double eCut_endc=0;
378  for (int ring=0; ring<kEndcEtaRings; ring++) {
379 
380  if(eta>e_.etaBoundary_[ring] && eta<e_.etaBoundary_[ring+1])
381  {
382  float eta_ring= abs(e_.cellPos_[ring][50].eta()) ;
383  eCut_endc = ap_ + eta_ring*b_;
384 
385  }
386  }
387 
388 
389  float et_thr = eCut_endc/cosh(eta) + 1.;
390 
391  if (e > eCut_endc && et < et_thr && e_.goodCell_endc[hit.ix()-1][hit.iy()-1][sign]){
392  etsum_endc_[hit.ix()-1][hit.iy()-1][sign] += et;
393  nhits_endc_[hit.ix()-1][hit.iy()-1][sign] ++;
394  pass=true;
395  }
396 
397 
398 
399  if (eventSet_==1) {
400  // apply a miscalibration to all crystals and increment the
401  // ET sum, combined for all crystals
402  for (int imiscal=0; imiscal<kNMiscalBinsEE; imiscal++) {
403  if (miscalEE_[imiscal]*e> eCut_endc && et*miscalEE_[imiscal] < et_thr && e_.goodCell_endc[hit.ix()-1][hit.iy()-1][sign]){
404  int ring = e_.endcapRing_[hit.ix()-1][hit.iy()-1];
405  etsum_endc_miscal_[imiscal][ring] += miscalEE_[imiscal]*et;
406  }
407  }
408 
409  // spectra stuff
410  if(spectra && hit.zside()>0) //POSITIVE!!!
411 
412  {
413  int ring = e_.endcapRing_[hit.ix()-1][hit.iy()-1];
414 
415  et_spectrum_e_histos[ring]->Fill(et*1000.);
416  e_spectrum_e_histos[ring]->Fill(e*1000.);
417 
418  if(ring==16)
419  {
420  //int iphi_endc = 0;
421  for (int ip=0; ip<e_.nRing_[ring]; ip++) {
422  //if (phi==e_.phi_endc_[ip][ring]) iphi_endc=ip;
423  }
424 
425  }
426  }//if spectra
427 
428  }//if eventSet_==1
429  }//for endc
430 
431  if (pass) {
432  nevents_++;
433  eventsinrun_++;
434  eventsinlb_++;
435  }
436 }
int ix() const
Definition: EEDetId.h:76
void setUp(const edm::EventSetup &setup)
int nRing_[kEndcEtaRings]
bool goodCell_barl[kBarlRings][kBarlWedges][kSides]
std::vector< TH1F * > et_spectrum_b_histos
std::vector< EcalRecHit >::const_iterator const_iterator
GlobalPoint cellPos_[kEndcWedgesX][kEndcWedgesY]
std::vector< TH1F * > e_spectrum_b_histos
T eta() const
EcalIntercalibConstants oldCalibs_
the old calibration constants (when reiterating, the last ones derived)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
double etsum_endc_miscal_[kNMiscalBinsEE][kEndcEtaRings]
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int endcapRing_[kEndcWedgesX][kEndcWedgesY]
static const int kEndcEtaRings
std::vector< TH1F * > et_spectrum_e_histos
double etsum_barl_miscal_[kNMiscalBinsEB][kBarlRings]
int zside() const
Definition: EEDetId.h:70
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int nhits_barl_[kBarlRings][kBarlWedges][kSides]
int iy() const
Definition: EEDetId.h:82
unsigned int nhits_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
const T & get() const
Definition: EventSetup.h:55
double etsum_barl_[kBarlRings][kBarlWedges][kSides]
double miscalEB_[kNMiscalBinsEB]
T eta() const
Definition: PV3DBase.h:76
std::vector< TH1F * > e_spectrum_e_histos
double etsum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
double miscalEE_[kNMiscalBinsEE]
bool goodCell_endc[kEndcWedgesX][kEndcWedgesX][kSides]
double etaBoundary_[kEndcEtaRings+1]
void PhiSymmetryCalibration::beginJob ( void  )
virtual

Called at beginning of job.

Reimplemented from edm::EDAnalyzer.

Definition at line 114 of file PhiSymmetryCalibration.cc.

References e_spectrum_b_histos, e_spectrum_e_histos, et_spectrum_b_histos, et_spectrum_e_histos, etsum_barl_, etsum_barl_miscal_, etsum_endc_, etsum_endc_miscal_, eventSet_, i, kBarlRings, kBarlWedges, kEndcEtaRings, kEndcWedgesX, kEndcWedgesY, kMiscalRangeEB, kMiscalRangeEE, kNMiscalBinsEB, kNMiscalBinsEE, kSides, miscalEB_, miscalEE_, nhits_barl_, nhits_endc_, relativeConstraints::ring, spectra, and edmStreamStallGrapher::t.

115 {
116 
117 
118  // initialize arrays
119  for (int sign=0; sign<kSides; sign++) {
120  for (int ieta=0; ieta<kBarlRings; ieta++) {
121  for (int iphi=0; iphi<kBarlWedges; iphi++) {
122  etsum_barl_[ieta][iphi][sign]=0.;
123  nhits_barl_[ieta][iphi][sign]=0;
124 
125  }
126  }
127  for (int ix=0; ix<kEndcWedgesX; ix++) {
128  for (int iy=0; iy<kEndcWedgesY; iy++) {
129  etsum_endc_[ix][iy][sign]=0.;
130  nhits_endc_[ix][iy][sign]=0;
131  }
132  }
133  }
134 
135 
136 
137  for (int imiscal=0; imiscal<kNMiscalBinsEB; imiscal++) {
138  miscalEB_[imiscal]= (1-kMiscalRangeEB) + float(imiscal)* (2*kMiscalRangeEB/(kNMiscalBinsEB-1));
139  for (int ieta=0; ieta<kBarlRings; ieta++) etsum_barl_miscal_[imiscal][ieta]=0.;
140  }
141 
142  for (int imiscal=0; imiscal<kNMiscalBinsEE; imiscal++) {
143  miscalEE_[imiscal]= (1-kMiscalRangeEE) + float(imiscal)* (2*kMiscalRangeEE/(kNMiscalBinsEE-1));
144  for (int ring=0; ring<kEndcEtaRings; ring++) etsum_endc_miscal_[imiscal][ring]=0.;
145  }
146 
147 
148 
149  // start spectra stuff
150  if (eventSet_!=1) spectra = false;
151 
152  if(spectra)
153  {
154  ostringstream t;
155  for(Int_t i=0;i<kBarlRings;i++)
156  {
157  t << "et_spectrum_b_" << i+1;
158  et_spectrum_b_histos[i]=new TH1F(t.str().c_str(),";E_{T} [MeV]",50,0.,500.);
159  t.str("");
160 
161  t << "e_spectrum_b_" << i+1;
162  e_spectrum_b_histos[i]=new TH1F(t.str().c_str(),";E [MeV]",50,0.,500.);
163  t.str("");
164 
165  }
166  for(Int_t i=0;i<kEndcEtaRings;i++)
167  {
168  t << "et_spectrum_e_" << i+1;
169  et_spectrum_e_histos[i]=new TH1F(t.str().c_str(),";E_{T} [MeV]",75,0.,1500.);
170  t.str("");
171 
172  t << "e_spectrum_e_" << i+1;
173  e_spectrum_e_histos[i]=new TH1F(t.str().c_str(),";E [MeV]",75,0.,1500.);
174  t.str("");
175 
176  }
177  }
178  // end spectra stuff
179 }
static const float kMiscalRangeEB
int i
Definition: DBlmapReader.cc:9
static const int kBarlRings
std::vector< TH1F * > et_spectrum_b_histos
static const int kSides
std::vector< TH1F * > e_spectrum_b_histos
static const int kBarlWedges
double etsum_endc_miscal_[kNMiscalBinsEE][kEndcEtaRings]
static const int kEndcWedgesX
static const int kEndcEtaRings
std::vector< TH1F * > et_spectrum_e_histos
double etsum_barl_miscal_[kNMiscalBinsEB][kBarlRings]
unsigned int nhits_barl_[kBarlRings][kBarlWedges][kSides]
unsigned int nhits_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
double etsum_barl_[kBarlRings][kBarlWedges][kSides]
double miscalEB_[kNMiscalBinsEB]
std::vector< TH1F * > e_spectrum_e_histos
double etsum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
double miscalEE_[kNMiscalBinsEE]
static const float kMiscalRangeEE
static const int kEndcWedgesY
void PhiSymmetryCalibration::endJob ( void  )
virtual

Called at end of job.

Reimplemented from edm::EDAnalyzer.

Definition at line 185 of file PhiSymmetryCalibration.cc.

References gather_cfg::cout, e_, e_spectrum_b_histos, e_spectrum_e_histos, EcalGeomPhiSymHelper::endcapRing_, et_spectrum_b_histos, et_spectrum_e_histos, etsum_barl_, etsum_endc_, eventSet_, f, getKfactors(), i, k_barl_, k_endc_, kBarlRings, kBarlWedges, kEndcEtaRings, kEndcWedgesX, kEndcWedgesY, kSides, nevents_, nhits_barl_, nhits_endc_, dbtoconf::out, relativeConstraints::ring, and spectra.

186 {
187 
188  edm::LogInfo("Calibration") << "[PhiSymmetryCalibration] At end of job";
189 
190  // start spectra stuff
191  if(spectra)
192  {
193  TFile f("Espectra_plus.root","recreate");
194 
195  for(int i=0;i<kBarlRings;i++){
196  et_spectrum_b_histos[i]->Write();
197  e_spectrum_b_histos[i]->Write();
198  }
199 
200  for(int i=0;i<kEndcEtaRings;i++){
201  et_spectrum_e_histos[i]->Write();
202  e_spectrum_e_histos[i]->Write();
203  }
204 
205  f.Close();
206  }
207 
208 
209 
210 
211  if (eventSet_==1) {
212  // calculate factors to convert from fractional deviation of ET sum from
213  // the mean to the estimate of the miscalibration factor
214  getKfactors();
215 
216  std::ofstream k_barl_out("k_barl.dat", ios::out);
217  for (int ieta=0; ieta<kBarlRings; ieta++)
218  k_barl_out << ieta << " " << k_barl_[ieta] << endl;
219  k_barl_out.close();
220 
221  std::ofstream k_endc_out("k_endc.dat", ios::out);
222  for (int ring=0; ring<kEndcEtaRings; ring++)
223  k_endc_out << ring << " " << k_endc_[ring] << endl;
224  k_endc_out.close();
225  }
226 
227 
228  if (eventSet_!=0) {
229  // output ET sums
230 
231  stringstream etsum_file_barl;
232  etsum_file_barl << "etsum_barl_"<<eventSet_<<".dat";
233 
234  std::ofstream etsum_barl_out(etsum_file_barl.str().c_str(),ios::out);
235 
236  for (int ieta=0; ieta<kBarlRings; ieta++) {
237  for (int iphi=0; iphi<kBarlWedges; iphi++) {
238  for (int sign=0; sign<kSides; sign++) {
239  etsum_barl_out << eventSet_ << " " << ieta << " " << iphi << " " << sign
240  << " " << etsum_barl_[ieta][iphi][sign] << " "
241  << nhits_barl_[ieta][iphi][sign] << endl;
242  }
243  }
244  }
245  etsum_barl_out.close();
246 
247  stringstream etsum_file_endc;
248  etsum_file_endc << "etsum_endc_"<<eventSet_<<".dat";
249 
250  std::ofstream etsum_endc_out(etsum_file_endc.str().c_str(),ios::out);
251  for (int ix=0; ix<kEndcWedgesX; ix++) {
252  for (int iy=0; iy<kEndcWedgesY; iy++) {
253  int ring = e_.endcapRing_[ix][iy];
254  if (ring!=-1) {
255  for (int sign=0; sign<kSides; sign++) {
256  etsum_endc_out << eventSet_ << " " << ix << " " << iy << " " << sign
257  << " " << etsum_endc_[ix][iy][sign] << " "
258  << nhits_endc_[ix][iy][sign]<<" "
259  << e_.endcapRing_[ix][iy]<<endl;
260  }
261  }
262  }
263  }
264  etsum_endc_out.close();
265  }
266  cout<<"Events processed " << nevents_<< endl;
267 }
int i
Definition: DBlmapReader.cc:9
static const int kBarlRings
std::vector< TH1F * > et_spectrum_b_histos
static const int kSides
std::vector< TH1F * > e_spectrum_b_histos
static const int kBarlWedges
static const int kEndcWedgesX
int endcapRing_[kEndcWedgesX][kEndcWedgesY]
static const int kEndcEtaRings
std::vector< TH1F * > et_spectrum_e_histos
double k_endc_[kEndcEtaRings]
unsigned int nhits_barl_[kBarlRings][kBarlWedges][kSides]
double f[11][100]
unsigned int nhits_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
tuple out
Definition: dbtoconf.py:99
double etsum_barl_[kBarlRings][kBarlWedges][kSides]
std::vector< TH1F * > e_spectrum_e_histos
tuple cout
Definition: gather_cfg.py:121
double etsum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
static const int kEndcWedgesY
void PhiSymmetryCalibration::endLuminosityBlock ( edm::LuminosityBlock const &  lb,
edm::EventSetup const &   
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 589 of file PhiSymmetryCalibration.cc.

References edm::LuminosityBlockBase::beginTime(), gather_cfg::cout, edm::LuminosityBlockBase::endTime(), eventsinlb_, edm::LuminosityBlockBase::id(), edm::LuminosityBlockBase::run(), and edm::Timestamp::value().

589  {
590 
591 
592  if ((lb.endTime().value()>>32)- (lb.beginTime().value()>>32) <60 )
593  return;
594 
595  std::cout << "PHILB : run "<< lb.run()
596  << " id " << lb.id()
597  << " start " << (lb.beginTime().value()>>32)
598  << " end " << (lb.endTime().value()>>32)
599  << " dur " << (lb.endTime().value()>>32)- (lb.beginTime().value()>>32)
600 
601  << " npass " << eventsinlb_ << std::endl;
602 
603  eventsinlb_=0;
604 
605 }
tuple cout
Definition: gather_cfg.py:121
void PhiSymmetryCalibration::endRun ( edm::Run run,
const edm::EventSetup  
)
virtual

Definition at line 438 of file PhiSymmetryCalibration.cc.

References edm::RunBase::beginTime(), gather_cfg::cout, edm::RunBase::endTime(), eventsinrun_, reco::return(), edm::RunBase::run(), and edm::Timestamp::value().

438  {
439 
440 
441  std::cout << "PHIREPRT : run "<< run.run()
442  << " start " << (run.beginTime().value()>>32)
443  << " end " << (run.endTime().value()>>32)
444  << " dur " << (run.endTime().value()>>32)- (run.beginTime().value()>>32)
445 
446  << " npass " << eventsinrun_ << std::endl;
447  eventsinrun_=0;
448 
449  return ;
450 
451 }
Timestamp const & endTime() const
Definition: RunBase.h:44
RunNumber_t run() const
Definition: RunBase.h:42
Timestamp const & beginTime() const
Definition: RunBase.h:43
return(e1-e2)*(e1-e2)+dp *dp
tuple cout
Definition: gather_cfg.py:121
TimeValue_t value() const
Definition: Timestamp.h:56
void PhiSymmetryCalibration::getKfactors ( )
private

Definition at line 455 of file PhiSymmetryCalibration.cc.

References gather_cfg::cout, etsum_barl_miscal_, etsum_endc_miscal_, f, k_barl_, k_endc_, kBarlRings, kEndcEtaRings, kMiscalRangeEB, kMiscalRangeEE, kNMiscalBinsEB, kNMiscalBinsEE, miscalEB_, miscalEE_, relativeConstraints::ring, and edmStreamStallGrapher::t.

Referenced by endJob().

456 {
457 
458  float epsilon_T_eb[kNMiscalBinsEB];
459  float epsilon_M_eb[kNMiscalBinsEB];
460 
461  float epsilon_T_ee[kNMiscalBinsEE];
462  float epsilon_M_ee[kNMiscalBinsEE];
463 
464  std::vector<TGraph*> k_barl_graph(kBarlRings);
465  std::vector<TCanvas*> k_barl_plot(kBarlRings);
466 
467  for (int ieta=0; ieta<kBarlRings; ieta++) {
468  for (int imiscal=0; imiscal<kNMiscalBinsEB; imiscal++) {
469  int middlebin = int (kNMiscalBinsEB/2);
470  epsilon_T_eb[imiscal] = etsum_barl_miscal_[imiscal][ieta]/etsum_barl_miscal_[middlebin][ieta] - 1.;
471  epsilon_M_eb[imiscal] = miscalEB_[imiscal] - 1.;
472  }
473  k_barl_graph[ieta] = new TGraph (kNMiscalBinsEB,epsilon_M_eb,epsilon_T_eb);
474  k_barl_graph[ieta]->Fit("pol1");
475 
476 
477  ostringstream t;
478  t<< "k_barl_" << ieta+1;
479  k_barl_plot[ieta] = new TCanvas(t.str().c_str(),"");
480  k_barl_plot[ieta]->SetFillColor(10);
481  k_barl_plot[ieta]->SetGrid();
482  k_barl_graph[ieta]->SetMarkerSize(1.);
483  k_barl_graph[ieta]->SetMarkerColor(4);
484  k_barl_graph[ieta]->SetMarkerStyle(20);
485  k_barl_graph[ieta]->GetXaxis()->SetLimits(-1.*kMiscalRangeEB,kMiscalRangeEB);
486  k_barl_graph[ieta]->GetXaxis()->SetTitleSize(.05);
487  k_barl_graph[ieta]->GetYaxis()->SetTitleSize(.05);
488  k_barl_graph[ieta]->GetXaxis()->SetTitle("#epsilon_{M}");
489  k_barl_graph[ieta]->GetYaxis()->SetTitle("#epsilon_{T}");
490  k_barl_graph[ieta]->Draw("AP");
491 
492  k_barl_[ieta] = k_barl_graph[ieta]->GetFunction("pol1")->GetParameter(1);
493  std::cout << "k_barl_[" << ieta << "]=" << k_barl_[ieta] << std::endl;
494  }
495 
496 
497  std::vector<TGraph*> k_endc_graph(kEndcEtaRings);
498  std::vector<TCanvas*> k_endc_plot(kEndcEtaRings);
499 
500  for (int ring=0; ring<kEndcEtaRings; ring++) {
501  for (int imiscal=0; imiscal<kNMiscalBinsEE; imiscal++) {
502  int middlebin = int (kNMiscalBinsEE/2);
503  epsilon_T_ee[imiscal] = etsum_endc_miscal_[imiscal][ring]/etsum_endc_miscal_[middlebin][ring] - 1.;
504  epsilon_M_ee[imiscal] = miscalEE_[imiscal] - 1.;
505  }
506  k_endc_graph[ring] = new TGraph (kNMiscalBinsEE,epsilon_M_ee,epsilon_T_ee);
507  k_endc_graph[ring]->Fit("pol1");
508 
509  ostringstream t;
510  t<< "k_endc_"<< ring+1;
511  k_endc_plot[ring] = new TCanvas(t.str().c_str(),"");
512  k_endc_plot[ring]->SetFillColor(10);
513  k_endc_plot[ring]->SetGrid();
514  k_endc_graph[ring]->SetMarkerSize(1.);
515  k_endc_graph[ring]->SetMarkerColor(4);
516  k_endc_graph[ring]->SetMarkerStyle(20);
517  k_endc_graph[ring]->GetXaxis()->SetLimits(-1*kMiscalRangeEE,kMiscalRangeEE);
518  k_endc_graph[ring]->GetXaxis()->SetTitleSize(.05);
519  k_endc_graph[ring]->GetYaxis()->SetTitleSize(.05);
520  k_endc_graph[ring]->GetXaxis()->SetTitle("#epsilon_{M}");
521  k_endc_graph[ring]->GetYaxis()->SetTitle("#epsilon_{T}");
522  k_endc_graph[ring]->Draw("AP");
523 
524  k_endc_[ring] = k_endc_graph[ring]->GetFunction("pol1")->GetParameter(1);
525  std::cout << "k_endc_[" << ring << "]=" << k_endc_[ring] << std::endl;
526  }
527 
528  TFile f("PhiSymmetryCalibration_kFactors.root","recreate");
529  for (int ieta=0; ieta<kBarlRings; ieta++) {
530  k_barl_plot[ieta]->Write();
531  delete k_barl_plot[ieta];
532  delete k_barl_graph[ieta];
533  }
534  for (int ring=0; ring<kEndcEtaRings; ring++) {
535  k_endc_plot[ring]->Write();
536  delete k_endc_plot[ring];
537  delete k_endc_graph[ring];
538  }
539  f.Close();
540 
541 }
static const float kMiscalRangeEB
static const int kBarlRings
double etsum_endc_miscal_[kNMiscalBinsEE][kEndcEtaRings]
static const int kEndcEtaRings
double etsum_barl_miscal_[kNMiscalBinsEB][kBarlRings]
double k_endc_[kEndcEtaRings]
double f[11][100]
double miscalEB_[kNMiscalBinsEB]
tuple cout
Definition: gather_cfg.py:121
double miscalEE_[kNMiscalBinsEE]
static const float kMiscalRangeEE
void PhiSymmetryCalibration::setUp ( const edm::EventSetup setup)

Definition at line 551 of file PhiSymmetryCalibration.cc.

References e_, edm::FileInPath::fullPath(), edm::EventSetup::get(), h, oldcalibfile_, oldCalibs_, EcalFloatCondObjectContainerXMLTranslator::readXML(), reiteration_, run_regression::ret, EcalGeomPhiSymHelper::setup(), and statusThreshold_.

Referenced by analyze().

551  {
552 
554  setup.get<EcalChannelStatusRcd>().get(chStatus);
555 
556  edm::ESHandle<CaloGeometry> geoHandle;
557  setup.get<CaloGeometryRecord>().get(geoHandle);
558 
559  e_.setup(&(*geoHandle), &(*chStatus), statusThreshold_);
560 
561 
562  if (reiteration_){
563 
565  // namespace fs = boost::filesystem;
566 // fs::path p(oldcalibfile_.c_str(),fs::native);
567 // if (!fs::exists(p)) edm::LogError("PhiSym") << "File not found: "
568 // << oldcalibfile_ <<endl;
569 
570  edm::FileInPath fip("Calibration/EcalCalibAlgos/data/"+oldcalibfile_);
571 
572 
573 
574  int ret=
576  if (ret) edm::LogError("PhiSym")<<"Error reading XML files"<<endl;;
577 
578  } else {
579  // in fact if not reiterating, oldCalibs_ will never be used
581  setup.get<EcalIntercalibConstantsRcd>().get(pIcal);
582  oldCalibs_=*pIcal;
583 
584  }
585 
586 }
void setup(const CaloGeometry *geometry, const EcalChannelStatus *chstatus, int statusThreshold)
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
EcalIntercalibConstants oldCalibs_
the old calibration constants (when reiterating, the last ones derived)
int statusThreshold_
threshold in channel status beyond which channel is marked bad
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const T & get() const
Definition: EventSetup.h:55

Member Data Documentation

double PhiSymmetryCalibration::ap_
private

Definition at line 133 of file PhiSymmetryCalibration.h.

Referenced by analyze().

double PhiSymmetryCalibration::b_
private

Definition at line 134 of file PhiSymmetryCalibration.h.

Referenced by analyze().

std::vector<DetId> PhiSymmetryCalibration::barrelCells
private

Definition at line 102 of file PhiSymmetryCalibration.h.

std::string PhiSymmetryCalibration::barrelHits_
private

Definition at line 125 of file PhiSymmetryCalibration.h.

Referenced by analyze().

EcalGeomPhiSymHelper PhiSymmetryCalibration::e_
private

Definition at line 76 of file PhiSymmetryCalibration.h.

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

std::vector<TH1F*> PhiSymmetryCalibration::e_spectrum_b_histos
private
std::vector<TH1F*> PhiSymmetryCalibration::e_spectrum_e_histos
private
std::string PhiSymmetryCalibration::ecalHitsProducer_
private

Definition at line 124 of file PhiSymmetryCalibration.h.

Referenced by analyze().

double PhiSymmetryCalibration::eCut_barl_
private

Definition at line 129 of file PhiSymmetryCalibration.h.

Referenced by analyze().

std::vector<DetId> PhiSymmetryCalibration::endcapCells
private

Definition at line 103 of file PhiSymmetryCalibration.h.

std::string PhiSymmetryCalibration::endcapHits_
private

Definition at line 126 of file PhiSymmetryCalibration.h.

Referenced by analyze().

float PhiSymmetryCalibration::epsilon_M_barl[kBarlRings][kBarlWedges][kSides]
private

Definition at line 114 of file PhiSymmetryCalibration.h.

float PhiSymmetryCalibration::epsilon_M_endc[kEndcWedgesX][kEndcWedgesY][kSides]
private

Definition at line 115 of file PhiSymmetryCalibration.h.

double PhiSymmetryCalibration::esumMean_barl_[kBarlRings]
private

Definition at line 92 of file PhiSymmetryCalibration.h.

double PhiSymmetryCalibration::esumMean_endc_[kEndcEtaRings]
private

Definition at line 93 of file PhiSymmetryCalibration.h.

std::vector<TH1F*> PhiSymmetryCalibration::et_spectrum_b_histos
private
std::vector<TH1F*> PhiSymmetryCalibration::et_spectrum_e_histos
private
double PhiSymmetryCalibration::etsum_barl_[kBarlRings][kBarlWedges][kSides]
private

Definition at line 79 of file PhiSymmetryCalibration.h.

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

double PhiSymmetryCalibration::etsum_barl_miscal_[kNMiscalBinsEB][kBarlRings]
private

Definition at line 88 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

double PhiSymmetryCalibration::etsum_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
private

Definition at line 80 of file PhiSymmetryCalibration.h.

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

double PhiSymmetryCalibration::etsum_endc_miscal_[kNMiscalBinsEE][kEndcEtaRings]
private

Definition at line 89 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

double PhiSymmetryCalibration::etsum_endc_uncorr[kEndcWedgesX][kEndcWedgesX][kSides]
private

Definition at line 81 of file PhiSymmetryCalibration.h.

double PhiSymmetryCalibration::etsumMean_barl_[kBarlRings]
private

Definition at line 82 of file PhiSymmetryCalibration.h.

double PhiSymmetryCalibration::etsumMean_endc_[kEndcEtaRings]
private

Definition at line 83 of file PhiSymmetryCalibration.h.

int PhiSymmetryCalibration::eventSet_
private

Definition at line 136 of file PhiSymmetryCalibration.h.

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

int PhiSymmetryCalibration::eventsinlb_
private

Definition at line 163 of file PhiSymmetryCalibration.h.

Referenced by analyze(), endLuminosityBlock(), and PhiSymmetryCalibration().

int PhiSymmetryCalibration::eventsinrun_
private

Definition at line 162 of file PhiSymmetryCalibration.h.

Referenced by analyze(), endRun(), and PhiSymmetryCalibration().

bool PhiSymmetryCalibration::isfirstpass_
private

Definition at line 151 of file PhiSymmetryCalibration.h.

Referenced by analyze(), and PhiSymmetryCalibration().

double PhiSymmetryCalibration::k_barl_[kBarlRings]
private

Definition at line 97 of file PhiSymmetryCalibration.h.

Referenced by endJob(), and getKfactors().

double PhiSymmetryCalibration::k_endc_[kEndcEtaRings]
private

Definition at line 98 of file PhiSymmetryCalibration.h.

Referenced by endJob(), and getKfactors().

const int PhiSymmetryCalibration::kMaxEndciPhi = 360
staticprivate

Definition at line 140 of file PhiSymmetryCalibration.h.

const float PhiSymmetryCalibration::kMiscalRangeEB = .05
staticprivate

Definition at line 71 of file PhiSymmetryCalibration.h.

Referenced by beginJob(), and getKfactors().

const float PhiSymmetryCalibration::kMiscalRangeEE = .10
staticprivate

Definition at line 74 of file PhiSymmetryCalibration.h.

Referenced by beginJob(), and getKfactors().

const int PhiSymmetryCalibration::kNMiscalBinsEB = 21
staticprivate

Definition at line 70 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

const int PhiSymmetryCalibration::kNMiscalBinsEE = 41
staticprivate

Definition at line 73 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

double PhiSymmetryCalibration::miscalEB_[kNMiscalBinsEB]
private

Definition at line 99 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

double PhiSymmetryCalibration::miscalEE_[kNMiscalBinsEE]
private

Definition at line 100 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), and getKfactors().

int PhiSymmetryCalibration::nevents_
private

Definition at line 161 of file PhiSymmetryCalibration.h.

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

double PhiSymmetryCalibration::newCalibs_barl[kBarlRings][kBarlWedges][kSides]
private

Definition at line 110 of file PhiSymmetryCalibration.h.

double PhiSymmetryCalibration::newCalibs_endc[kEndcWedgesX][kEndcWedgesX][kSides]
private

Definition at line 111 of file PhiSymmetryCalibration.h.

unsigned int PhiSymmetryCalibration::nhits_barl_[kBarlRings][kBarlWedges][kSides]
private

Definition at line 85 of file PhiSymmetryCalibration.h.

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

unsigned int PhiSymmetryCalibration::nhits_endc_[kEndcWedgesX][kEndcWedgesX][kSides]
private

Definition at line 86 of file PhiSymmetryCalibration.h.

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

std::string PhiSymmetryCalibration::oldcalibfile_
private

Definition at line 146 of file PhiSymmetryCalibration.h.

Referenced by setUp().

EcalIntercalibConstants PhiSymmetryCalibration::oldCalibs_
private

the old calibration constants (when reiterating, the last ones derived)

Definition at line 149 of file PhiSymmetryCalibration.h.

Referenced by analyze(), and setUp().

double PhiSymmetryCalibration::oldCalibs_barl[kBarlRings][kBarlWedges][kSides]
private

Definition at line 106 of file PhiSymmetryCalibration.h.

double PhiSymmetryCalibration::oldCalibs_endc[kEndcWedgesX][kEndcWedgesY][kSides]
private

Definition at line 107 of file PhiSymmetryCalibration.h.

float PhiSymmetryCalibration::phi_endc[kMaxEndciPhi][kEndcEtaRings]
private

Definition at line 142 of file PhiSymmetryCalibration.h.

float PhiSymmetryCalibration::rawconst_barl[kBarlRings][kBarlWedges][kSides]
private

Definition at line 118 of file PhiSymmetryCalibration.h.

float PhiSymmetryCalibration::rawconst_endc[kEndcWedgesX][kEndcWedgesX][kSides]
private

Definition at line 119 of file PhiSymmetryCalibration.h.

bool PhiSymmetryCalibration::reiteration_
private

Definition at line 145 of file PhiSymmetryCalibration.h.

Referenced by analyze(), and setUp().

bool PhiSymmetryCalibration::spectra
private

Definition at line 160 of file PhiSymmetryCalibration.h.

Referenced by analyze(), beginJob(), endJob(), and PhiSymmetryCalibration().

int PhiSymmetryCalibration::statusThreshold_
private

threshold in channel status beyond which channel is marked bad

Definition at line 138 of file PhiSymmetryCalibration.h.

Referenced by setUp().