CMS 3D CMS Logo

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

#include <EcalABAnalyzer.h>

Inheritance diagram for EcalABAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Types

enum  VarCol { iBlue, iRed, nColor }
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase 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::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const double _alpha
 
const double _beta
 
const double _chi2cut
 
const int _debug
 
const std::string _ecalPart
 
const int _fedid
 
const unsigned int _firstsample
 
bool _fitab
 
const unsigned int _lastsample
 
const unsigned int _nevtmax
 
const unsigned int _niter
 
const double _noise
 
const unsigned int _nsamples
 
unsigned int _presample
 
const double _presamplecut
 
const double _qualpercent
 
const double _ratiomaxcutlow
 
const double _ratiomincuthigh
 
const double _ratiomincutlow
 
const unsigned int _timingcuthigh
 
const unsigned int _timingcutlow
 
const unsigned int _timingqualhigh
 
const 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
 
const std::string digiCollection_
 
const std::string digiProducer_
 
bool doesABTreeExist
 
edm::EDGetTokenT
< EBDigiCollection
ebDigiToken_
 
edm::EDGetTokenT
< EEDigiCollection
eeDigiToken_
 
int eta
 
int event
 
const std::string eventHeaderCollection_
 
const 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
 
const edm::ESGetToken
< EcalElectronicsMapping,
EcalMappingRcd
mappingToken_
 
std::vector< int > modules
 
unsigned int nCrys
 
unsigned int nevtAB [1700]
 
int nEvtBadGain [1700]
 
int nEvtBadTiming [1700]
 
int nEvtTot [1700]
 
int phi
 
const edm::EDGetTokenT
< EcalRawDataCollection
rawDataToken_
 
const 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::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 40 of file EcalABAnalyzer.h.

Member Enumeration Documentation

Enumerator
iBlue 
iRed 
nColor 

Definition at line 49 of file EcalABAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 41 of file EcalABAnalyzer.cc.

References _ecalPart, _fedid, _firstsample, _fitab, _lastsample, _nsamples, _presample, _ratiomaxcutlow, _ratiomincuthigh, _ratiomincutlow, _timingcuthigh, _timingcutlow, _timingqualhigh, _timingquallow, APDPulse, Delta01, Delta12, digiCollection_, digiProducer_, ebDigiToken_, eeDigiToken_, iChannelID, idccID, iEta, HLT_FULL_cff::InputTag, iPhi, isGainOK, iside, isTimingOK, iTowerID, iZ, dqmiolumiharvest::j, nCrys, NCRYSEB, NCRYSEE, nevtAB, wasGainOK, and wasTimingOK.

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

Definition at line 147 of file EcalABAnalyzer.cc.

147  {
148  //========================================================================
149 
150  // do anything here that needs to be done at desctruction time
151  // (e.g. close files, deallocate resources etc.)
152 }

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 223 of file EcalABAnalyzer.cc.

References _ecalPart, _fedid, _fitab, _nevtmax, adc, adcG, TMom::addEntry(), APDPulse, cms::cuda::assert(), edm::SortedCollection< T, SORT >::begin(), edm::DataFrameContainer::begin(), EcalElectronicsId::channelId(), channelIteratorEE, channelMapEE, color, colors, dccID, Delta01, Delta12, isotrackApplyRegressor::df, digiCollection_, doesABTreeExist, ebDigiToken_, eeDigiToken_, MEEBGeom::electronic_channel(), edm::SortedCollection< T, SORT >::end(), edm::DataFrameContainer::end(), eta, eventHeaderCollection_, eventHeaderProducer_, fedID, spr::find(), edm::Event::getByToken(), edm::EventSetup::getData(), TAPDPulse::getDelta(), ecalpyutils::hashedIndex(), mps_fire::i, iChannelID, idccID, iEta, iEvent, iPhi, iside, TAPDPulse::isPulseOK(), TAPDPulse::isTimingQualOK(), edm::HandleBase::isValid(), iTowerID, iZ, EcalDCCHeaderBlock::LASER_DELAY_SCAN, EcalDCCHeaderBlock::LASER_GAP, EcalDCCHeaderBlock::LASER_POWER_SCAN, EcalDCCHeaderBlock::LASER_STD, lightside, MEEBGeom::localCoord(), mappingToken_, Max(), nCrys, nevtAB, nEvtBadGain, nEvtBadTiming, nEvtTot, phi, edm::Handle< T >::product(), TShapeAnalysis::putAllVals(), rawDataToken_, 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().

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

Definition at line 155 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.

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 507 of file EcalABAnalyzer.cc.

References _ecalPart, _fitab, _presample, _presamplecut, _qualpercent, alphafile, alphainitfile, APDPulse, channelMapEE, TShapeAnalysis::computeShape(), 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().

507  {
508  //========================================================================
509 
510  edm::LogVerbatim("EcalABAnalyzer") << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
511  edm::LogVerbatim("EcalABAnalyzer") << "\t+=+ Analyzing data: getting (alpha, beta) +=+";
512 
513  // Adjust channel numbers for EE
514  //===============================
515 
516  if (_ecalPart == "EE") {
517  nCrys = channelMapEE.size();
519  }
520 
521  // Set presamples number
522  //======================
523 
524  double delta01 = Delta01->getMean();
525  double delta12 = Delta12->getMean();
526  if (delta12 > _presamplecut) {
527  _presample = 2;
528  if (delta01 > _presamplecut)
529  _presample = 1;
530  }
531 
534 
535  // Get alpha and beta
536  //======================
537 
538  if (_fitab) {
539  edm::LogVerbatim("EcalABAnalyzer") << "\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
540  edm::LogVerbatim("EcalABAnalyzer") << "\t+=+ Analyzing data: getting (alpha, beta) +=+";
541  TFile* fAB = nullptr;
542  TTree* ABInit = nullptr;
543  if (doesABTreeExist) {
544  fAB = new TFile(alphainitfile.c_str());
545  }
546  if (doesABTreeExist && fAB) {
547  ABInit = (TTree*)fAB->Get("ABCol0");
548  }
549  shapana->computeShape(alphafile, ABInit);
550 
551  // Set quality flags for gains and timing
552 
553  double BadGainEvtPercentage = 0.0;
554  double BadTimingEvtPercentage = 0.0;
555 
556  int nChanBadGain = 0;
557  int nChanBadTiming = 0;
558 
559  for (unsigned int i = 0; i < nCrys; i++) {
560  if (nEvtTot[i] != 0) {
561  BadGainEvtPercentage = double(nEvtBadGain[i]) / double(nEvtTot[i]);
562  BadTimingEvtPercentage = double(nEvtBadTiming[i]) / double(nEvtTot[i]);
563  }
564  if (BadGainEvtPercentage > _qualpercent) {
565  wasGainOK[i] = false;
566  nChanBadGain++;
567  }
568  if (BadTimingEvtPercentage > _qualpercent) {
569  wasTimingOK[i] = false;
570  nChanBadTiming++;
571  }
572  }
573 
574  double BadGainChanPercentage = double(nChanBadGain) / double(nCrys);
575  double BadTimingChanPercentage = double(nChanBadTiming) / double(nCrys);
576 
577  if (BadGainChanPercentage > _qualpercent)
578  isGainOK = false;
579  if (BadTimingChanPercentage > _qualpercent)
580  isTimingOK = false;
581 
582  if (!isGainOK)
583  edm::LogVerbatim("EcalABAnalyzer") << "\t+=+ ............................ WARNING! APD GAIN WAS NOT 1 +=+";
584  if (!isTimingOK)
585  edm::LogVerbatim("EcalABAnalyzer") << "\t+=+ ............................ WARNING! TIMING WAS BAD +=+";
586 
587  edm::LogVerbatim("EcalABAnalyzer") << "\t+=+ .................................... done +=+";
588  edm::LogVerbatim("EcalABAnalyzer") << "\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
589  }
590 }
Log< level::Info, true > LogVerbatim
unsigned int nCrys
int nEvtBadGain[1700]
const double _qualpercent
std::string alphainitfile
void computeShape(std::string namefile, TTree *)
const std::string _ecalPart
std::string alphafile
const 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

const double EcalABAnalyzer::_alpha
private

Definition at line 79 of file EcalABAnalyzer.h.

Referenced by beginJob().

const double EcalABAnalyzer::_beta
private

Definition at line 80 of file EcalABAnalyzer.h.

Referenced by beginJob().

const double EcalABAnalyzer::_chi2cut
private

Definition at line 83 of file EcalABAnalyzer.h.

Referenced by beginJob().

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

Definition at line 84 of file EcalABAnalyzer.h.

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

const int EcalABAnalyzer::_fedid
private

Definition at line 85 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

const unsigned int EcalABAnalyzer::_firstsample
private

Definition at line 68 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

bool EcalABAnalyzer::_fitab
private

Definition at line 109 of file EcalABAnalyzer.h.

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

const unsigned int EcalABAnalyzer::_lastsample
private

Definition at line 69 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

const unsigned int EcalABAnalyzer::_nevtmax
private

Definition at line 81 of file EcalABAnalyzer.h.

Referenced by analyze(), and beginJob().

const unsigned int EcalABAnalyzer::_niter
private

Definition at line 78 of file EcalABAnalyzer.h.

const double EcalABAnalyzer::_noise
private

Definition at line 82 of file EcalABAnalyzer.h.

Referenced by beginJob().

const unsigned int EcalABAnalyzer::_nsamples
private

Definition at line 66 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

unsigned int EcalABAnalyzer::_presample
private

Definition at line 67 of file EcalABAnalyzer.h.

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

const double EcalABAnalyzer::_presamplecut
private

Definition at line 77 of file EcalABAnalyzer.h.

Referenced by endJob().

const double EcalABAnalyzer::_qualpercent
private

Definition at line 86 of file EcalABAnalyzer.h.

Referenced by endJob().

const double EcalABAnalyzer::_ratiomaxcutlow
private

Definition at line 76 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

const double EcalABAnalyzer::_ratiomincuthigh
private

Definition at line 75 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

const double EcalABAnalyzer::_ratiomincutlow
private

Definition at line 74 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

const unsigned int EcalABAnalyzer::_timingcuthigh
private

Definition at line 71 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

const unsigned int EcalABAnalyzer::_timingcutlow
private

Definition at line 70 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

const unsigned int EcalABAnalyzer::_timingqualhigh
private

Definition at line 73 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

const unsigned int EcalABAnalyzer::_timingquallow
private

Definition at line 72 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

double EcalABAnalyzer::adc[10]
private

Definition at line 132 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::adcG[10]
private

Definition at line 133 of file EcalABAnalyzer.h.

Referenced by analyze().

std::string EcalABAnalyzer::alphafile
private

Definition at line 97 of file EcalABAnalyzer.h.

Referenced by beginJob(), and endJob().

std::string EcalABAnalyzer::alphainitfile
private

Definition at line 98 of file EcalABAnalyzer.h.

Referenced by beginJob(), and endJob().

TAPDPulse* EcalABAnalyzer::APDPulse
private

Definition at line 89 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::channelIteratorEE
private

Definition at line 134 of file EcalABAnalyzer.h.

Referenced by analyze().

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

Definition at line 123 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::color
private

Definition at line 131 of file EcalABAnalyzer.h.

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

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

Definition at line 122 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::dccID
private

Definition at line 115 of file EcalABAnalyzer.h.

Referenced by analyze().

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

Definition at line 124 of file EcalABAnalyzer.h.

TMom* EcalABAnalyzer::Delta01
private

Definition at line 90 of file EcalABAnalyzer.h.

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

TMom* EcalABAnalyzer::Delta12
private

Definition at line 91 of file EcalABAnalyzer.h.

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

const std::string EcalABAnalyzer::digiCollection_
private

Definition at line 56 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

const std::string EcalABAnalyzer::digiProducer_
private

Definition at line 57 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

bool EcalABAnalyzer::doesABTreeExist
private

Definition at line 107 of file EcalABAnalyzer.h.

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

edm::EDGetTokenT<EBDigiCollection> EcalABAnalyzer::ebDigiToken_
private

Definition at line 60 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

edm::EDGetTokenT<EEDigiCollection> EcalABAnalyzer::eeDigiToken_
private

Definition at line 61 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

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

Definition at line 54 of file EcalABAnalyzer.h.

Referenced by analyze().

const std::string EcalABAnalyzer::eventHeaderProducer_
private

Definition at line 55 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::fedID
private

Definition at line 114 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::iChannelID[1700]
private

Definition at line 137 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::idccID[1700]
private

Definition at line 137 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iEta[1700]
private

Definition at line 136 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iEvent
private

Definition at line 52 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::iPhi[1700]
private

Definition at line 136 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::isGainOK
private

Definition at line 148 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

int EcalABAnalyzer::iside[1700]
private

Definition at line 137 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::isTimingOK
private

Definition at line 149 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

int EcalABAnalyzer::iTowerID[1700]
private

Definition at line 137 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iZ
private

Definition at line 118 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::lightside
private

Definition at line 117 of file EcalABAnalyzer.h.

Referenced by analyze().

const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> EcalABAnalyzer::mappingToken_
private

Definition at line 62 of file EcalABAnalyzer.h.

Referenced by analyze().

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

Definition at line 125 of file EcalABAnalyzer.h.

unsigned int EcalABAnalyzer::nCrys
private

Definition at line 106 of file EcalABAnalyzer.h.

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

unsigned int EcalABAnalyzer::nevtAB[1700]
private

Definition at line 101 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::nEvtBadGain[1700]
private

Definition at line 141 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::nEvtBadTiming[1700]
private

Definition at line 142 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::nEvtTot[1700]
private

Definition at line 143 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::phi
private
const edm::EDGetTokenT<EcalRawDataCollection> EcalABAnalyzer::rawDataToken_
private

Definition at line 59 of file EcalABAnalyzer.h.

Referenced by analyze().

const std::string EcalABAnalyzer::resdir_
private

Definition at line 93 of file EcalABAnalyzer.h.

Referenced by beginJob().

int EcalABAnalyzer::runNum
private

Definition at line 113 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::runType
private

Definition at line 112 of file EcalABAnalyzer.h.

Referenced by analyze().

TShapeAnalysis* EcalABAnalyzer::shapana
private

Definition at line 100 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::side
private

Definition at line 116 of file EcalABAnalyzer.h.

Referenced by analyze().

bool EcalABAnalyzer::wasGainOK[1700]
private

Definition at line 145 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

bool EcalABAnalyzer::wasTimingOK[1700]
private

Definition at line 146 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().