CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
EcalABAnalyzer Class Reference

#include <EcalABAnalyzer.h>

Inheritance diagram for EcalABAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

enum  VarCol { iBlue, iRed, nColor }
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
 EcalABAnalyzer (const edm::ParameterSet &iConfig)
 
void endJob () override
 
 ~EcalABAnalyzer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double _alpha
 
double _beta
 
double _chi2cut
 
int _debug
 
std::string _ecalPart
 
int _fedid
 
unsigned int _firstsample
 
bool _fitab
 
unsigned int _lastsample
 
unsigned int _nevtmax
 
unsigned int _niter
 
double _noise
 
unsigned int _nsamples
 
unsigned int _presample
 
double _presamplecut
 
double _qualpercent
 
double _ratiomaxcutlow
 
double _ratiomincuthigh
 
double _ratiomincutlow
 
unsigned int _timingcuthigh
 
unsigned int _timingcutlow
 
unsigned int _timingqualhigh
 
unsigned int _timingquallow
 
double adc [10]
 
int adcG [10]
 
std::string alphafile
 
std::string alphainitfile
 
TAPDPulseAPDPulse
 
int channelIteratorEE
 
std::map< int, int > channelMapEE
 
int color
 
std::vector< int > colors
 
int dccID
 
std::vector< int > dccMEM
 
TMomDelta01
 
TMomDelta12
 
std::string digiCollection_
 
std::string digiProducer_
 
bool doesABTreeExist
 
int eta
 
int event
 
std::string eventHeaderCollection_
 
std::string eventHeaderProducer_
 
int fedID
 
int iChannelID [1700]
 
int idccID [1700]
 
int iEta [1700]
 
int iEvent
 
int iPhi [1700]
 
bool isGainOK
 
int iside [1700]
 
bool isTimingOK
 
int iTowerID [1700]
 
int iZ
 
int lightside
 
std::vector< int > modules
 
unsigned int nCrys
 
unsigned int nevtAB [1700]
 
int nEvtBadGain [1700]
 
int nEvtBadTiming [1700]
 
int nEvtTot [1700]
 
int phi
 
std::string resdir_
 
int runNum
 
int runType
 
TShapeAnalysisshapana
 
int side
 
bool wasGainOK [1700]
 
bool wasTimingOK [1700]
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 EcalABAnalyzer.h.

Member Enumeration Documentation

Enumerator
iBlue 
iRed 
nColor 

Definition at line 44 of file EcalABAnalyzer.h.

Constructor & Destructor Documentation

EcalABAnalyzer::EcalABAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 52 of file EcalABAnalyzer.cc.

References _ecalPart, _fedid, _firstsample, _fitab, _lastsample, _nsamples, _presample, _ratiomaxcutlow, _ratiomincuthigh, _ratiomincutlow, _timingcuthigh, _timingcutlow, _timingqualhigh, _timingquallow, APDPulse, Delta01, Delta12, digiCollection_, digiProducer_, eventHeaderCollection_, eventHeaderProducer_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), iChannelID, idccID, iEta, iPhi, isGainOK, iside, isTimingOK, iTowerID, iZ, dqmiolumiharvest::j, nCrys, NCRYSEB, NCRYSEE, nevtAB, resdir_, AlCaHLTBitMon_QueryRunRegistry::string, wasGainOK, and wasTimingOK.

54  : iEvent(0),
55 
56  // framework parameters with default values
57  _nsamples(iConfig.getUntrackedParameter<unsigned int>("nSamples", 10)),
58  _presample(iConfig.getUntrackedParameter<unsigned int>("nPresamples", 2)),
59  _firstsample(iConfig.getUntrackedParameter<unsigned int>("firstSample", 1)),
60  _lastsample(iConfig.getUntrackedParameter<unsigned int>("lastSample", 2)),
61  _timingcutlow(iConfig.getUntrackedParameter<unsigned int>("timingCutLow", 2)),
62  _timingcuthigh(iConfig.getUntrackedParameter<unsigned int>("timingCutHigh", 9)),
63  _timingquallow(iConfig.getUntrackedParameter<unsigned int>("timingQualLow", 3)),
64  _timingqualhigh(iConfig.getUntrackedParameter<unsigned int>("timingQualHigh", 8)),
65  _ratiomincutlow(iConfig.getUntrackedParameter<double>("ratioMinCutLow", 0.4)),
66  _ratiomincuthigh(iConfig.getUntrackedParameter<double>("ratioMinCutHigh", 0.95)),
67  _ratiomaxcutlow(iConfig.getUntrackedParameter<double>("ratioMaxCutLow", 0.8)),
68  _presamplecut(iConfig.getUntrackedParameter<double>("presampleCut", 5.0)),
69  _niter(iConfig.getUntrackedParameter<unsigned int>("nIter", 3)),
70  _alpha(iConfig.getUntrackedParameter<double>("alpha", 1.5076494)),
71  _beta(iConfig.getUntrackedParameter<double>("beta", 1.5136036)),
72  _nevtmax(iConfig.getUntrackedParameter<unsigned int>("nEvtMax", 200)),
73  _noise(iConfig.getUntrackedParameter<double>("noise", 2.0)),
74  _chi2cut(iConfig.getUntrackedParameter<double>("chi2cut", 100.0)),
75  _ecalPart(iConfig.getUntrackedParameter<std::string>("ecalPart", "EB")),
76  _qualpercent(iConfig.getUntrackedParameter<double>("qualPercent", 0.2)),
77  _debug(iConfig.getUntrackedParameter<int>("debug", 0)),
78  nCrys(NCRYSEB),
79  runType(-1),
80  runNum(0),
81  fedID(-1),
82  dccID(-1),
83  side(2),
84  lightside(2),
85  iZ(1),
86  phi(-1),
87  eta(-1),
88  event(0),
89  color(-1),
91 
92 //========================================================================
93 
94 {
95  // Initialization from cfg file
96 
97  resdir_ = iConfig.getUntrackedParameter<std::string>("resDir");
98 
99  digiCollection_ = iConfig.getParameter<std::string>("digiCollection");
100  digiProducer_ = iConfig.getParameter<std::string>("digiProducer");
101 
102  eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
103  eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
104 
105  // Geometrical constants initialization
106 
107  if (_ecalPart == "EB") {
108  nCrys = NCRYSEB;
109  } else {
110  nCrys = NCRYSEE;
111  }
112  iZ = 1;
113  if (_fedid <= 609)
114  iZ = -1;
115 
116  for (unsigned int j = 0; j < nCrys; j++) {
117  iEta[j] = -1;
118  iPhi[j] = -1;
119  iTowerID[j] = -1;
120  iChannelID[j] = -1;
121  idccID[j] = -1;
122  iside[j] = -1;
123  wasTimingOK[j] = true;
124  wasGainOK[j] = true;
125  nevtAB[j] = 0;
126  }
127 
128  // Quality check flags
129 
130  isGainOK = true;
131  isTimingOK = true;
132 
133  // Objects dealing with pulses
134 
136  _presample,
137  _firstsample,
138  _lastsample,
146 
147  // Objects needed for npresample calculation
148 
149  Delta01 = new TMom();
150  Delta12 = new TMom();
151  _fitab = true;
152 }
T getParameter(std::string const &) const
unsigned int nCrys
T getUntrackedParameter(std::string const &, T const &) const
std::string digiProducer_
std::string eventHeaderProducer_
std::string _ecalPart
int idccID[1700]
double _ratiomaxcutlow
#define NCRYSEE
double _ratiomincuthigh
unsigned int _nsamples
unsigned int _firstsample
Definition: TMom.h:7
unsigned int _nevtmax
unsigned int _niter
double _presamplecut
#define NCRYSEB
int iChannelID[1700]
int iTowerID[1700]
unsigned int nevtAB[1700]
unsigned int _timingcuthigh
std::string resdir_
unsigned int _lastsample
TAPDPulse * APDPulse
std::string digiCollection_
unsigned int _timingqualhigh
unsigned int _presample
std::string eventHeaderCollection_
double _ratiomincutlow
unsigned int _timingcutlow
bool wasTimingOK[1700]
unsigned int _timingquallow
bool wasGainOK[1700]
EcalABAnalyzer::~EcalABAnalyzer ( )
override

Definition at line 155 of file EcalABAnalyzer.cc.

155  {
156  //========================================================================
157 
158  // do anything here that needs to be done at desctruction time
159  // (e.g. close files, deallocate resources etc.)
160 }

Member Function Documentation

void EcalABAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 231 of file EcalABAnalyzer.cc.

References _ecalPart, _fedid, _fitab, _nevtmax, adc, adcG, TMom::addEntry(), APDPulse, edm::SortedCollection< T, SORT >::begin(), edm::DataFrameContainer::begin(), beam_dqm_sourceclient-live_cfg::cerr, EcalElectronicsId::channelId(), channelIteratorEE, channelMapEE, color, gather_cfg::cout, dccID, Delta01, Delta12, digiCollection_, digiProducer_, doesABTreeExist, CollectionTags_cfi::EBDigi, CollectionTags_cfi::EEDigi, MEEBGeom::electronic_channel(), edm::SortedCollection< T, SORT >::end(), edm::DataFrameContainer::end(), eta, eventHeaderCollection_, eventHeaderProducer_, cppFunctionSkipper::exception, fedID, spr::find(), edm::EventSetup::get(), edm::Event::getByLabel(), TAPDPulse::getDelta(), EcalElectronicsMapping::getElectronicsId(), ecalpyutils::hashedIndex(), mps_fire::i, iChannelID, idccID, iEta, iEvent, iPhi, iside, TAPDPulse::isPulseOK(), TAPDPulse::isTimingQualOK(), iTowerID, iZ, EcalDCCHeaderBlock::LASER_DELAY_SCAN, EcalDCCHeaderBlock::LASER_GAP, EcalDCCHeaderBlock::LASER_POWER_SCAN, EcalDCCHeaderBlock::LASER_STD, lightside, MEEBGeom::localCoord(), Max(), nCrys, nevtAB, nEvtBadGain, nEvtBadTiming, nEvtTot, phi, edm::Handle< T >::product(), edm::ESHandle< T >::product(), TShapeAnalysis::putAllVals(), runNum, runType, TAPDPulse::setPulse(), shapana, MEEBGeom::side(), MEEEGeom::side(), side, digitizers_cfi::strip, EcalElectronicsId::stripId(), ecaldqm::towerID(), EcalElectronicsId::towerId(), EcalDCCHeaderBlock::EcalDCCEventSettings::wavelength, and EcalElectronicsId::xtalId().

231  {
232  //========================================================================
233 
234  ++iEvent;
235 
236  // retrieving DCC header
238  const EcalRawDataCollection* DCCHeader = nullptr;
239  try {
241  DCCHeader = pDCCHeader.product();
242  } catch (std::exception& ex) {
243  std::cerr << "Error! can't get the product retrieving DCC header" << eventHeaderCollection_.c_str() << " "
244  << eventHeaderProducer_.c_str() << std::endl;
245  }
246 
247  //retrieving crystal data from Event
249  const EBDigiCollection* EBDigi = nullptr;
251  const EEDigiCollection* EEDigi = nullptr;
252  if (_ecalPart == "EB") {
253  try {
255  EBDigi = pEBDigi.product();
256  } catch (std::exception& ex) {
257  std::cerr << "Error! can't get the product retrieving EB crystal data " << digiCollection_.c_str() << std::endl;
258  }
259  } else if (_ecalPart == "EE") {
260  try {
262  EEDigi = pEEDigi.product();
263  } catch (std::exception& ex) {
264  std::cerr << "Error! can't get the product retrieving EE crystal data " << digiCollection_.c_str() << std::endl;
265  }
266  } else {
267  std::cout << " Wrong ecalPart in cfg file " << std::endl;
268  return;
269  }
270 
271  // retrieving electronics mapping
273  const EcalElectronicsMapping* TheMapping = nullptr;
274  try {
275  c.get<EcalMappingRcd>().get(ecalmapping);
276  TheMapping = ecalmapping.product();
277  } catch (std::exception& ex) {
278  std::cerr << "Error! can't get the product EcalMappingRcd" << std::endl;
279  }
280 
281  // =============================
282  // Decode DCCHeader Information
283  // =============================
284 
285  for (EcalRawDataCollection::const_iterator headerItr = DCCHeader->begin(); headerItr != DCCHeader->end();
286  ++headerItr) {
287  // Get run type and run number
288 
289  int fed = headerItr->fedId();
290  if (fed != _fedid && _fedid != -999)
291  continue;
292 
293  runType = headerItr->getRunType();
294  runNum = headerItr->getRunNumber();
295  event = headerItr->getLV1();
296 
297  dccID = headerItr->getDccInTCCCommand();
298  fedID = headerItr->fedId();
299  lightside = headerItr->getRtHalf();
300 
301  // Check fed corresponds to the DCC in TCC
302 
303  if (600 + dccID != fedID)
304  continue;
305 
306  // Cut on runType
307 
310  return;
311 
312  // Retrieve laser color and event number
313 
314  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
315  color = settings.wavelength;
316  if (color < 0)
317  return;
318 
319  std::vector<int>::iterator iter = find(colors.begin(), colors.end(), color);
320  if (iter == colors.end()) {
321  colors.push_back(color);
322  }
323  }
324 
325  // Cut on fedID
326 
327  if (fedID != _fedid && _fedid != -999)
328  return;
329 
330  // ===========================
331  // Decode EBDigis Information
332  // ===========================
333 
334  int adcGain = 0;
335 
336  if (EBDigi) {
337  // Loop on crystals
338  //===================
339 
340  for (EBDigiCollection::const_iterator digiItr = EBDigi->begin(); digiItr != EBDigi->end();
341  ++digiItr) { // Loop on crystals
342 
343  // Retrieve geometry
344  //===================
345 
346  EBDetId id_crystal(digiItr->id());
347  EBDataFrame df(*digiItr);
348 
349  int etaG = id_crystal.ieta(); // global
350  int phiG = id_crystal.iphi(); // global
351 
352  int etaL; // local
353  int phiL; // local
354  std::pair<int, int> LocalCoord = MEEBGeom::localCoord(etaG, phiG);
355 
356  etaL = LocalCoord.first;
357  phiL = LocalCoord.second;
358 
359  eta = etaG;
360  phi = phiG;
361 
362  side = MEEBGeom::side(etaG, phiG);
363 
364  // Recover the TT id and the electronic crystal numbering from EcalElectronicsMapping
365 
366  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
367 
368  int towerID = elecid_crystal.towerId();
369  int strip = elecid_crystal.stripId();
370  int xtal = elecid_crystal.xtalId();
371  int channelID = 5 * (strip - 1) + xtal - 1;
372 
373  unsigned int channel = MEEBGeom::electronic_channel(etaL, phiL);
374 
375  assert(channel < nCrys);
376 
377  iEta[channel] = eta;
378  iPhi[channel] = phi;
379  iTowerID[channel] = towerID;
380  iChannelID[channel] = channelID;
381  idccID[channel] = dccID;
382  iside[channel] = side;
383 
384  // APD Pulse
385  //===========
386 
387  // Loop on adc samples
388 
389  for (unsigned int i = 0; i < (*digiItr).size(); ++i) {
390  EcalMGPASample samp_crystal(df.sample(i));
391  adc[i] = samp_crystal.adc();
392  adcG[i] = samp_crystal.gainId();
393  adc[i] *= adcG[i];
394  if (i == 0)
395  adcGain = adcG[i];
396  if (i > 0)
397  adcGain = TMath::Max(adcG[i], adcGain);
398  }
399 
400  APDPulse->setPulse(adc);
401 
402  // Quality checks
403  //================
404 
405  if (adcGain != 1)
406  nEvtBadGain[channel]++;
407  if (!APDPulse->isTimingQualOK())
408  nEvtBadTiming[channel]++;
409  nEvtTot[channel]++;
410 
411  // Fill if Pulse is fine
412  //=======================
413 
414  if (APDPulse->isPulseOK() && lightside == side) {
417 
418  if (nevtAB[channel] < _nevtmax && _fitab) {
419  if (doesABTreeExist)
420  shapana->putAllVals(channel, adc, eta, phi);
421  else
422  shapana->putAllVals(channel, adc, eta, phi, dccID, side, towerID, channelID);
423  nevtAB[channel]++;
424  }
425  }
426  }
427 
428  } else if (EEDigi) {
429  // Loop on crystals
430  //===================
431 
432  for (EEDigiCollection::const_iterator digiItr = EEDigi->begin(); digiItr != EEDigi->end();
433  ++digiItr) { // Loop on crystals
434 
435  // Retrieve geometry
436  //===================
437 
438  EEDetId id_crystal(digiItr->id());
439  EEDataFrame df(*digiItr);
440 
441  phi = id_crystal.ix();
442  eta = id_crystal.iy();
443 
444  int iX = (phi - 1) / 5 + 1;
445  int iY = (eta - 1) / 5 + 1;
446 
447  side = MEEEGeom::side(iX, iY, iZ);
448  EcalElectronicsId elecid_crystal = TheMapping->getElectronicsId(id_crystal);
449 
450  int towerID = elecid_crystal.towerId();
451  int channelID = elecid_crystal.channelId() - 1;
452 
453  int hashedIndex = 100000 * eta + phi;
454 
455  if (channelMapEE.count(hashedIndex) == 0) {
458  }
459 
460  unsigned int channel = channelMapEE[hashedIndex];
461 
462  assert(channel < nCrys);
463 
464  iEta[channel] = eta;
465  iPhi[channel] = phi;
466  iTowerID[channel] = towerID;
467  iChannelID[channel] = channelID;
468  idccID[channel] = dccID;
469  iside[channel] = side;
470 
471  // APD Pulse
472  //===========
473 
474  if ((*digiItr).size() > 10)
475  std::cout << "SAMPLES SIZE > 10!" << (*digiItr).size() << std::endl;
476 
477  // Loop on adc samples
478 
479  for (unsigned int i = 0; i < (*digiItr).size(); ++i) {
480  EcalMGPASample samp_crystal(df.sample(i));
481  adc[i] = samp_crystal.adc();
482  adcG[i] = samp_crystal.gainId();
483  adc[i] *= adcG[i];
484 
485  if (i == 0)
486  adcGain = adcG[i];
487  if (i > 0)
488  adcGain = TMath::Max(adcG[i], adcGain);
489  }
490 
491  APDPulse->setPulse(adc);
492 
493  // Quality checks
494  //================
495 
496  if (adcGain != 1)
497  nEvtBadGain[channel]++;
498  if (!APDPulse->isTimingQualOK())
499  nEvtBadTiming[channel]++;
500  nEvtTot[channel]++;
501 
502  // Fill if Pulse is fine
503  //=======================
504 
505  if (APDPulse->isPulseOK() && lightside == side) {
508 
509  if (nevtAB[channel] < _nevtmax && _fitab) {
510  if (doesABTreeExist)
511  shapana->putAllVals(channel, adc, eta, phi);
512  else
513  shapana->putAllVals(channel, adc, eta, phi, dccID, side, towerID, channelID);
514  nevtAB[channel]++;
515  }
516  }
517  }
518  }
519 } // analyze
void addEntry(double val)
Definition: TMom.cc:88
static XYCoord localCoord(int icr)
Definition: MEEBGeom.cc:142
unsigned int nCrys
int nEvtBadGain[1700]
std::string digiProducer_
int xtalId() const
get the channel id
std::string eventHeaderProducer_
std::string _ecalPart
int idccID[1700]
int stripId() const
get the tower id
double getDelta(int, int)
Definition: TAPDPulse.cc:116
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
bool setPulse(double *)
Definition: TAPDPulse.cc:86
static int side(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
Definition: MEEEGeom.cc:1155
std::vector< T >::const_iterator const_iterator
int towerId() const
get the tower id
const_iterator begin() const
void putAllVals(int, double *, int, int)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
unsigned int _nevtmax
double adc[10]
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
Definition: MEEBGeom.cc:326
int iChannelID[1700]
int iTowerID[1700]
int nEvtTot[1700]
TShapeAnalysis * shapana
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
unsigned int nevtAB[1700]
const_iterator end() const
T Max(T a, T b)
Definition: MathUtil.h:44
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:105
bool isTimingQualOK()
Definition: TAPDPulse.cc:145
T const * product() const
Definition: Handle.h:69
std::map< int, int > channelMapEE
TAPDPulse * APDPulse
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const_iterator end() const
std::string digiCollection_
bool isPulseOK()
Definition: TAPDPulse.cc:162
std::string eventHeaderCollection_
Definition: colors.py:1
T get() const
Definition: EventSetup.h:73
EcalLogicID towerID(EcalElectronicsId const &)
T const * product() const
Definition: ESHandle.h:86
int channelId() const
so far for EndCap only :
const_iterator begin() const
int adc() const
get the ADC sample (12 bits)
int nEvtBadTiming[1700]
void EcalABAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 163 of file EcalABAnalyzer.cc.

References _alpha, _beta, _chi2cut, _firstsample, _fitab, _lastsample, _nevtmax, _noise, _nsamples, _presample, alphafile, alphainitfile, doesABTreeExist, MainPageGenerator::link, resdir_, TShapeAnalysis::set_const(), shapana, and ctpps_dqm_sourceclient-live_cfg::test.

163  {
164  //========================================================================
165 
166  //Calculate alpha and beta
167 
168  // Define output results filenames and shape analyzer object (alpha,beta)
169  //=====================================================================
170 
171  // 1) AlphaBeta files
172 
173  doesABTreeExist = true;
174 
175  std::stringstream nameabinitfile;
176  nameabinitfile << resdir_ << "/ABInit.root";
177  alphainitfile = nameabinitfile.str();
178 
179  std::stringstream nameabfile;
180  std::stringstream link;
181  nameabfile << resdir_ << "/AB.root";
182 
183  FILE* test;
184  test = fopen(nameabinitfile.str().c_str(), "r");
185  if (test == nullptr) {
186  doesABTreeExist = false;
187  _fitab = true;
188  };
189  delete test;
190 
191  TFile* fAB = nullptr;
192  TTree* ABInit = nullptr;
193  if (doesABTreeExist) {
194  fAB = new TFile(nameabinitfile.str().c_str());
195  }
196  if (doesABTreeExist && fAB) {
197  ABInit = (TTree*)fAB->Get("ABCol0");
198  }
199 
200  // 2) Shape analyzer
201 
202  if (doesABTreeExist && fAB && ABInit && ABInit->GetEntries() != 0) {
203  shapana = new TShapeAnalysis(ABInit, _alpha, _beta, 5.5, 1.0);
204  doesABTreeExist = true;
205  } else {
206  shapana = new TShapeAnalysis(_alpha, _beta, 5.5, 1.0);
207  doesABTreeExist = false;
208  _fitab = true;
209  }
211 
212  if (doesABTreeExist && fAB)
213  fAB->Close();
214 
215  if (_fitab) {
216  alphafile = nameabfile.str();
217  } else {
219  link << "ln -s " << resdir_ << "/ABInit.root " << resdir_ << "/AB.root";
220  system(link.str().c_str());
221  }
222 
223  // Define output results files' names
224 
225  std::stringstream namefile;
226  namefile << resdir_ << "/AB.root";
227  alphafile = namefile.str();
228 }
std::string alphainitfile
unsigned int _nsamples
unsigned int _firstsample
unsigned int _nevtmax
std::string alphafile
TShapeAnalysis * shapana
std::string resdir_
unsigned int _lastsample
void set_const(int, int, int, int, int, double, double)
unsigned int _presample
void EcalABAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 522 of file EcalABAnalyzer.cc.

References _ecalPart, _fitab, _presample, _presamplecut, _qualpercent, alphafile, alphainitfile, APDPulse, channelMapEE, TShapeAnalysis::computeShape(), gather_cfg::cout, DEFINE_FWK_MODULE, Delta01, Delta12, doesABTreeExist, TMom::getMean(), mps_fire::i, isGainOK, isTimingOK, nCrys, nEvtBadGain, nEvtBadTiming, nEvtTot, TShapeAnalysis::set_nch(), TShapeAnalysis::set_presample(), TAPDPulse::setPresamples(), shapana, wasGainOK, and wasTimingOK.

Referenced by o2olib.O2ORunMgr::executeJob().

522  {
523  //========================================================================
524 
525  std::cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
526  std::cout << "\t+=+ Analyzing data: getting (alpha, beta) +=+" << std::endl;
527 
528  // Adjust channel numbers for EE
529  //===============================
530 
531  if (_ecalPart == "EE") {
532  nCrys = channelMapEE.size();
534  }
535 
536  // Set presamples number
537  //======================
538 
539  double delta01 = Delta01->getMean();
540  double delta12 = Delta12->getMean();
541  if (delta12 > _presamplecut) {
542  _presample = 2;
543  if (delta01 > _presamplecut)
544  _presample = 1;
545  }
546 
549 
550  // Get alpha and beta
551  //======================
552 
553  if (_fitab) {
554  std::cout << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
555  std::cout << "\t+=+ Analyzing data: getting (alpha, beta) +=+" << std::endl;
556  TFile* fAB = nullptr;
557  TTree* ABInit = nullptr;
558  if (doesABTreeExist) {
559  fAB = new TFile(alphainitfile.c_str());
560  }
561  if (doesABTreeExist && fAB) {
562  ABInit = (TTree*)fAB->Get("ABCol0");
563  }
564  shapana->computeShape(alphafile, ABInit);
565 
566  // Set quality flags for gains and timing
567 
568  double BadGainEvtPercentage = 0.0;
569  double BadTimingEvtPercentage = 0.0;
570 
571  int nChanBadGain = 0;
572  int nChanBadTiming = 0;
573 
574  for (unsigned int i = 0; i < nCrys; i++) {
575  if (nEvtTot[i] != 0) {
576  BadGainEvtPercentage = double(nEvtBadGain[i]) / double(nEvtTot[i]);
577  BadTimingEvtPercentage = double(nEvtBadTiming[i]) / double(nEvtTot[i]);
578  }
579  if (BadGainEvtPercentage > _qualpercent) {
580  wasGainOK[i] = false;
581  nChanBadGain++;
582  }
583  if (BadTimingEvtPercentage > _qualpercent) {
584  wasTimingOK[i] = false;
585  nChanBadTiming++;
586  }
587  }
588 
589  double BadGainChanPercentage = double(nChanBadGain) / double(nCrys);
590  double BadTimingChanPercentage = double(nChanBadTiming) / double(nCrys);
591 
592  if (BadGainChanPercentage > _qualpercent)
593  isGainOK = false;
594  if (BadTimingChanPercentage > _qualpercent)
595  isTimingOK = false;
596 
597  if (!isGainOK)
598  std::cout << "\t+=+ ............................ WARNING! APD GAIN WAS NOT 1 +=+" << std::endl;
599  if (!isTimingOK)
600  std::cout << "\t+=+ ............................ WARNING! TIMING WAS BAD +=+" << std::endl;
601 
602  std::cout << "\t+=+ .................................... done +=+" << std::endl;
603  std::cout << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
604  }
605 }
unsigned int nCrys
int nEvtBadGain[1700]
std::string alphainitfile
std::string _ecalPart
void computeShape(std::string namefile, TTree *)
std::string alphafile
double _presamplecut
int nEvtTot[1700]
TShapeAnalysis * shapana
std::map< int, int > channelMapEE
TAPDPulse * APDPulse
void setPresamples(int)
Definition: TAPDPulse.cc:251
unsigned int _presample
void set_presample(int)
bool wasTimingOK[1700]
double getMean()
Definition: TMom.cc:121
bool wasGainOK[1700]
int nEvtBadTiming[1700]

Member Data Documentation

double EcalABAnalyzer::_alpha
private

Definition at line 64 of file EcalABAnalyzer.h.

Referenced by beginJob().

double EcalABAnalyzer::_beta
private

Definition at line 65 of file EcalABAnalyzer.h.

Referenced by beginJob().

double EcalABAnalyzer::_chi2cut
private

Definition at line 68 of file EcalABAnalyzer.h.

Referenced by beginJob().

int EcalABAnalyzer::_debug
private
std::string EcalABAnalyzer::_ecalPart
private

Definition at line 69 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::_fedid
private

Definition at line 70 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

unsigned int EcalABAnalyzer::_firstsample
private

Definition at line 53 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

bool EcalABAnalyzer::_fitab
private

Definition at line 98 of file EcalABAnalyzer.h.

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

unsigned int EcalABAnalyzer::_lastsample
private

Definition at line 54 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

unsigned int EcalABAnalyzer::_nevtmax
private

Definition at line 66 of file EcalABAnalyzer.h.

Referenced by analyze(), and beginJob().

unsigned int EcalABAnalyzer::_niter
private

Definition at line 63 of file EcalABAnalyzer.h.

double EcalABAnalyzer::_noise
private

Definition at line 67 of file EcalABAnalyzer.h.

Referenced by beginJob().

unsigned int EcalABAnalyzer::_nsamples
private

Definition at line 51 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

unsigned int EcalABAnalyzer::_presample
private

Definition at line 52 of file EcalABAnalyzer.h.

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

double EcalABAnalyzer::_presamplecut
private

Definition at line 62 of file EcalABAnalyzer.h.

Referenced by endJob().

double EcalABAnalyzer::_qualpercent
private

Definition at line 71 of file EcalABAnalyzer.h.

Referenced by endJob().

double EcalABAnalyzer::_ratiomaxcutlow
private

Definition at line 61 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

double EcalABAnalyzer::_ratiomincuthigh
private

Definition at line 60 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

double EcalABAnalyzer::_ratiomincutlow
private

Definition at line 59 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingcuthigh
private

Definition at line 56 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingcutlow
private

Definition at line 55 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingqualhigh
private

Definition at line 58 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingquallow
private

Definition at line 57 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

double EcalABAnalyzer::adc[10]
private

Definition at line 121 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::adcG[10]
private

Definition at line 122 of file EcalABAnalyzer.h.

Referenced by analyze().

std::string EcalABAnalyzer::alphafile
private

Definition at line 86 of file EcalABAnalyzer.h.

Referenced by beginJob(), and endJob().

std::string EcalABAnalyzer::alphainitfile
private

Definition at line 87 of file EcalABAnalyzer.h.

Referenced by beginJob(), and endJob().

TAPDPulse* EcalABAnalyzer::APDPulse
private

Definition at line 74 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::channelIteratorEE
private

Definition at line 123 of file EcalABAnalyzer.h.

Referenced by analyze().

std::map<int, int> EcalABAnalyzer::channelMapEE
private

Definition at line 112 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::color
private

Definition at line 120 of file EcalABAnalyzer.h.

Referenced by analyze(), and edmStreamStallGrapher.StreamInfoElement::unpack().

std::vector<int> EcalABAnalyzer::colors
private

Definition at line 111 of file EcalABAnalyzer.h.

int EcalABAnalyzer::dccID
private

Definition at line 104 of file EcalABAnalyzer.h.

Referenced by analyze().

std::vector<int> EcalABAnalyzer::dccMEM
private

Definition at line 113 of file EcalABAnalyzer.h.

TMom* EcalABAnalyzer::Delta01
private

Definition at line 75 of file EcalABAnalyzer.h.

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

TMom* EcalABAnalyzer::Delta12
private

Definition at line 76 of file EcalABAnalyzer.h.

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

std::string EcalABAnalyzer::digiCollection_
private

Definition at line 79 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

std::string EcalABAnalyzer::digiProducer_
private

Definition at line 80 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::doesABTreeExist
private

Definition at line 96 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::eta
private
int EcalABAnalyzer::event
private
std::string EcalABAnalyzer::eventHeaderCollection_
private

Definition at line 81 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

std::string EcalABAnalyzer::eventHeaderProducer_
private

Definition at line 82 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::fedID
private

Definition at line 103 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::iChannelID[1700]
private

Definition at line 126 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::idccID[1700]
private

Definition at line 126 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iEta[1700]
private

Definition at line 125 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iEvent
private

Definition at line 47 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::iPhi[1700]
private

Definition at line 125 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::isGainOK
private

Definition at line 137 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

int EcalABAnalyzer::iside[1700]
private

Definition at line 126 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::isTimingOK
private

Definition at line 138 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

int EcalABAnalyzer::iTowerID[1700]
private

Definition at line 126 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iZ
private

Definition at line 107 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::lightside
private

Definition at line 106 of file EcalABAnalyzer.h.

Referenced by analyze().

std::vector<int> EcalABAnalyzer::modules
private

Definition at line 114 of file EcalABAnalyzer.h.

unsigned int EcalABAnalyzer::nCrys
private

Definition at line 95 of file EcalABAnalyzer.h.

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

unsigned int EcalABAnalyzer::nevtAB[1700]
private

Definition at line 90 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::nEvtBadGain[1700]
private

Definition at line 130 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::nEvtBadTiming[1700]
private

Definition at line 131 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::nEvtTot[1700]
private

Definition at line 132 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::phi
private
std::string EcalABAnalyzer::resdir_
private

Definition at line 78 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

int EcalABAnalyzer::runNum
private

Definition at line 102 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::runType
private

Definition at line 101 of file EcalABAnalyzer.h.

Referenced by analyze().

TShapeAnalysis* EcalABAnalyzer::shapana
private

Definition at line 89 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::side
private

Definition at line 105 of file EcalABAnalyzer.h.

Referenced by analyze().

bool EcalABAnalyzer::wasGainOK[1700]
private

Definition at line 134 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

bool EcalABAnalyzer::wasTimingOK[1700]
private

Definition at line 135 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().