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 ()
 
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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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 &)
 
- 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 EcalABAnalyzer.h.

Member Enumeration Documentation

Enumerator
iBlue 
iRed 
nColor 

Definition at line 48 of file EcalABAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 53 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, nCrys, NCRYSEB, NCRYSEE, nevtAB, resdir_, AlCaHLTBitMon_QueryRunRegistry::string, wasGainOK, and wasTimingOK.

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

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

Member Function Documentation

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

Definition at line 229 of file EcalABAnalyzer.cc.

References _ecalPart, _fedid, _fitab, _nevtmax, adc, adcG, TMom::addEntry(), APDPulse, edm::SortedCollection< T, SORT >::begin(), edm::DataFrameContainer::begin(), MessageLogger_cfi::cerr, EcalElectronicsId::channelId(), channelIteratorEE, channelMapEE, color, gather_cfg::cout, dccID, Delta01, Delta12, digiCollection_, digiProducer_, doesABTreeExist, 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(), runNum, runType, TAPDPulse::setPulse(), shapana, MEEBGeom::side(), MEEEGeom::side(), side, digi_MixPreMix_cfi::strip, EcalElectronicsId::stripId(), ecaldqm::towerID(), EcalElectronicsId::towerId(), EcalDCCHeaderBlock::EcalDCCEventSettings::wavelength, and EcalElectronicsId::xtalId().

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

References _alpha, _beta, _chi2cut, _firstsample, _fitab, _lastsample, _nevtmax, _noise, _nsamples, _presample, alphafile, alphainitfile, doesABTreeExist, resdir_, shapana, and PFTauMVAInputDiscriminatorTranslator_cfi::test.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 514 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().

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

Member Data Documentation

double EcalABAnalyzer::_alpha
private

Definition at line 70 of file EcalABAnalyzer.h.

Referenced by beginJob().

double EcalABAnalyzer::_beta
private

Definition at line 71 of file EcalABAnalyzer.h.

Referenced by beginJob().

double EcalABAnalyzer::_chi2cut
private

Definition at line 74 of file EcalABAnalyzer.h.

Referenced by beginJob().

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

Definition at line 75 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::_fedid
private

Definition at line 76 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

unsigned int EcalABAnalyzer::_firstsample
private

Definition at line 59 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

bool EcalABAnalyzer::_fitab
private

Definition at line 104 of file EcalABAnalyzer.h.

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

unsigned int EcalABAnalyzer::_lastsample
private

Definition at line 60 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

unsigned int EcalABAnalyzer::_nevtmax
private

Definition at line 72 of file EcalABAnalyzer.h.

Referenced by analyze(), and beginJob().

unsigned int EcalABAnalyzer::_niter
private

Definition at line 69 of file EcalABAnalyzer.h.

double EcalABAnalyzer::_noise
private

Definition at line 73 of file EcalABAnalyzer.h.

Referenced by beginJob().

unsigned int EcalABAnalyzer::_nsamples
private

Definition at line 57 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

unsigned int EcalABAnalyzer::_presample
private

Definition at line 58 of file EcalABAnalyzer.h.

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

double EcalABAnalyzer::_presamplecut
private

Definition at line 68 of file EcalABAnalyzer.h.

Referenced by endJob().

double EcalABAnalyzer::_qualpercent
private

Definition at line 77 of file EcalABAnalyzer.h.

Referenced by endJob().

double EcalABAnalyzer::_ratiomaxcutlow
private

Definition at line 67 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

double EcalABAnalyzer::_ratiomincuthigh
private

Definition at line 66 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

double EcalABAnalyzer::_ratiomincutlow
private

Definition at line 65 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingcuthigh
private

Definition at line 62 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingcutlow
private

Definition at line 61 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingqualhigh
private

Definition at line 64 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

unsigned int EcalABAnalyzer::_timingquallow
private

Definition at line 63 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer().

double EcalABAnalyzer::adc[10]
private

Definition at line 129 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::adcG[10]
private

Definition at line 130 of file EcalABAnalyzer.h.

Referenced by analyze().

std::string EcalABAnalyzer::alphafile
private

Definition at line 92 of file EcalABAnalyzer.h.

Referenced by beginJob(), and endJob().

std::string EcalABAnalyzer::alphainitfile
private

Definition at line 93 of file EcalABAnalyzer.h.

Referenced by beginJob(), and endJob().

TAPDPulse* EcalABAnalyzer::APDPulse
private

Definition at line 80 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::channelIteratorEE
private

Definition at line 131 of file EcalABAnalyzer.h.

Referenced by analyze().

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

Definition at line 119 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::color
private

Definition at line 128 of file EcalABAnalyzer.h.

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

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

Definition at line 118 of file EcalABAnalyzer.h.

int EcalABAnalyzer::dccID
private

Definition at line 110 of file EcalABAnalyzer.h.

Referenced by analyze().

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

Definition at line 120 of file EcalABAnalyzer.h.

TMom* EcalABAnalyzer::Delta01
private

Definition at line 81 of file EcalABAnalyzer.h.

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

TMom* EcalABAnalyzer::Delta12
private

Definition at line 82 of file EcalABAnalyzer.h.

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

std::string EcalABAnalyzer::digiCollection_
private

Definition at line 85 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

std::string EcalABAnalyzer::digiProducer_
private

Definition at line 86 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::doesABTreeExist
private

Definition at line 102 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 87 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

std::string EcalABAnalyzer::eventHeaderProducer_
private

Definition at line 88 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::fedID
private

Definition at line 109 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::iChannelID[1700]
private

Definition at line 135 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::idccID[1700]
private

Definition at line 135 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iEta[1700]
private

Definition at line 134 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 134 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::isGainOK
private

Definition at line 146 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

int EcalABAnalyzer::iside[1700]
private

Definition at line 135 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

bool EcalABAnalyzer::isTimingOK
private

Definition at line 147 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

int EcalABAnalyzer::iTowerID[1700]
private

Definition at line 135 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::iZ
private

Definition at line 113 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::lightside
private

Definition at line 112 of file EcalABAnalyzer.h.

Referenced by analyze().

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

Definition at line 121 of file EcalABAnalyzer.h.

unsigned int EcalABAnalyzer::nCrys
private

Definition at line 101 of file EcalABAnalyzer.h.

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

unsigned int EcalABAnalyzer::nevtAB[1700]
private

Definition at line 96 of file EcalABAnalyzer.h.

Referenced by analyze(), and EcalABAnalyzer().

int EcalABAnalyzer::nEvtBadGain[1700]
private

Definition at line 139 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::nEvtBadTiming[1700]
private

Definition at line 140 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

int EcalABAnalyzer::nEvtTot[1700]
private

Definition at line 141 of file EcalABAnalyzer.h.

Referenced by analyze(), and endJob().

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

Definition at line 84 of file EcalABAnalyzer.h.

Referenced by beginJob(), and EcalABAnalyzer().

int EcalABAnalyzer::runNum
private

Definition at line 108 of file EcalABAnalyzer.h.

Referenced by analyze().

int EcalABAnalyzer::runType
private

Definition at line 107 of file EcalABAnalyzer.h.

Referenced by analyze().

TShapeAnalysis* EcalABAnalyzer::shapana
private

Definition at line 95 of file EcalABAnalyzer.h.

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

int EcalABAnalyzer::side
private

Definition at line 111 of file EcalABAnalyzer.h.

Referenced by analyze().

bool EcalABAnalyzer::wasGainOK[1700]
private

Definition at line 143 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().

bool EcalABAnalyzer::wasTimingOK[1700]
private

Definition at line 144 of file EcalABAnalyzer.h.

Referenced by EcalABAnalyzer(), and endJob().