CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
EcalMipGraphs Class Reference

#include <EcalMipGraphs.h>

Inheritance diagram for EcalMipGraphs:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 EcalMipGraphs (const edm::ParameterSet &)
 
 ~EcalMipGraphs () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
std::string floatToString (float num)
 
int getEEIndex (EcalElectronicsId elecId)
 
void initHists (int)
 
std::string intToString (int num)
 
TGraph * selectDigi (DetId det, int ievt)
 
void selectHits (edm::Handle< EcalRecHitCollection > hits, int ievt)
 
void writeGraphs ()
 

Private Attributes

int abscissa [10]
 
TH1F * allFedsTimingHist_
 
const CaloTopologycaloTopo_
 
TTree * canvasNames_
 
std::map< int, float > crysAndAmplitudesMap_
 
const edm::InputTag EBDigis_
 
edm::Handle< EBDigiCollectionEBdigisHandle
 
const edm::EDGetTokenT< EBDigiCollectionebDigiToken_
 
const edm::InputTag EBRecHitCollection_
 
const edm::EDGetTokenT< EcalRecHitCollectionebRecHitToken_
 
const EcalElectronicsMappingecalElectronicsMap_
 
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcdecalMappingToken_
 
const edm::InputTag EEDigis_
 
edm::Handle< EEDigiCollectionEEdigisHandle
 
const edm::EDGetTokenT< EEDigiCollectioneeDigiToken_
 
const edm::InputTag EERecHitCollection_
 
const edm::EDGetTokenT< EcalRecHitCollectioneeRecHitToken_
 
EcalFedMapfedMap_
 
std::map< int, EcalDCCHeaderBlockFEDsAndDCCHeaders_
 
std::map< int, TH1F * > FEDsAndTimingHists_
 
TFile * file_
 
const edm::InputTag headerProducer_
 
std::set< EBDetIdlistEBChannels
 
std::set< EEDetIdlistEEChannels
 
std::vector< int > maskedChannels_
 
std::vector< std::string > maskedEBs_
 
std::vector< int > maskedFEDs_
 
const double minTimingAmp_
 
int naiveEvtNum_
 
std::vector< std::string > * names
 
int ordinate [10]
 
const edm::EDGetTokenT< EcalRawDataCollectionrawDataToken_
 
int runNum_
 
std::vector< int > seedCrys_
 
std::map< std::string, int > seedFrequencyMap_
 
const int side_
 
const double threshold_
 
const edm::ESGetToken< CaloTopology, CaloTopologyRecordtopologyToken_
 

Static Private Attributes

static edm::Service< TFileServicefileService
 
static float gainRatio [3] = {1., 2., 12.}
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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< Bconsumes (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 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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 59 of file EcalMipGraphs.h.

Constructor & Destructor Documentation

◆ EcalMipGraphs()

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

Definition at line 40 of file EcalMipGraphs.cc.

References abscissa, allFedsTimingHist_, fedMap_, fileService, EcalFedMap::getFedFromSlice(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, TFileService::make(), maskedChannels_, maskedEBs_, maskedFEDs_, naiveEvtNum_, and seedCrys_.

41  : EBRecHitCollection_(iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEB")),
42  EERecHitCollection_(iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEE")),
43  EBDigis_(iConfig.getParameter<edm::InputTag>("EBDigiCollection")),
44  EEDigis_(iConfig.getParameter<edm::InputTag>("EEDigiCollection")),
45  headerProducer_(iConfig.getParameter<edm::InputTag>("headerProducer")),
46  rawDataToken_(consumes<EcalRawDataCollection>(headerProducer_)),
47  ebRecHitToken_(consumes<EcalRecHitCollection>(EBRecHitCollection_)),
48  eeRecHitToken_(consumes<EcalRecHitCollection>(EERecHitCollection_)),
49  ebDigiToken_(consumes<EBDigiCollection>(EBDigis_)),
50  eeDigiToken_(consumes<EEDigiCollection>(EEDigis_)),
51  ecalMappingToken_(esConsumes<edm::Transition::BeginRun>()),
53  runNum_(-1),
54  side_(iConfig.getUntrackedParameter<int>("side", 3)),
55  threshold_(iConfig.getUntrackedParameter<double>("amplitudeThreshold", 12.0)),
56  minTimingAmp_(iConfig.getUntrackedParameter<double>("minimumTimingAmplitude", 0.100)) {
57  vector<int> listDefaults;
58  listDefaults.push_back(-1);
59 
60  maskedChannels_ = iConfig.getUntrackedParameter<vector<int> >("maskedChannels", listDefaults);
61  maskedFEDs_ = iConfig.getUntrackedParameter<vector<int> >("maskedFEDs", listDefaults);
62  seedCrys_ = iConfig.getUntrackedParameter<vector<int> >("seedCrys", vector<int>());
63 
64  vector<string> defaultMaskedEBs;
65  defaultMaskedEBs.push_back("none");
66  maskedEBs_ = iConfig.getUntrackedParameter<vector<string> >("maskedEBs", defaultMaskedEBs);
67 
68  fedMap_ = new EcalFedMap();
69 
70  string title1 = "Jitter for all FEDs";
71  string name1 = "JitterAllFEDs";
72  allFedsTimingHist_ = fileService->make<TH1F>(name1.c_str(), title1.c_str(), 150, -7, 7);
73 
74  // load up the maskedFED list with the proper FEDids
75  if (maskedFEDs_[0] == -1) {
76  //if "actual" EB id given, then convert to FEDid and put in listFEDs_
77  if (maskedEBs_[0] != "none") {
78  maskedFEDs_.clear();
79  for (vector<string>::const_iterator ebItr = maskedEBs_.begin(); ebItr != maskedEBs_.end(); ++ebItr) {
80  maskedFEDs_.push_back(fedMap_->getFedFromSlice(*ebItr));
81  }
82  }
83  }
84 
85  for (int i = 0; i < 10; i++)
86  abscissa[i] = i;
87 
88  naiveEvtNum_ = 0;
89 }
const edm::InputTag EEDigis_
Definition: EcalMipGraphs.h:82
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< int > maskedFEDs_
const edm::EDGetTokenT< EEDigiCollection > eeDigiToken_
Definition: EcalMipGraphs.h:92
EcalFedMap * fedMap_
int getFedFromSlice(std::string)
Definition: EcalFedMap.cc:96
std::vector< std::string > maskedEBs_
static edm::Service< TFileService > fileService
int abscissa[10]
const edm::EDGetTokenT< EcalRawDataCollection > rawDataToken_
Definition: EcalMipGraphs.h:88
T getUntrackedParameter(std::string const &, T const &) const
const int side_
Definition: EcalMipGraphs.h:98
const edm::InputTag EBRecHitCollection_
Definition: EcalMipGraphs.h:79
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > ecalMappingToken_
Definition: EcalMipGraphs.h:94
const edm::InputTag EERecHitCollection_
Definition: EcalMipGraphs.h:80
const double threshold_
Definition: EcalMipGraphs.h:99
std::vector< int > seedCrys_
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHitToken_
Definition: EcalMipGraphs.h:89
std::vector< int > maskedChannels_
const edm::InputTag EBDigis_
Definition: EcalMipGraphs.h:81
const edm::EDGetTokenT< EBDigiCollection > ebDigiToken_
Definition: EcalMipGraphs.h:91
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > topologyToken_
Definition: EcalMipGraphs.h:95
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHitToken_
Definition: EcalMipGraphs.h:90
const edm::InputTag headerProducer_
Definition: EcalMipGraphs.h:83
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
const double minTimingAmp_
TH1F * allFedsTimingHist_

◆ ~EcalMipGraphs()

EcalMipGraphs::~EcalMipGraphs ( )
override

Definition at line 91 of file EcalMipGraphs.cc.

91 {}

Member Function Documentation

◆ analyze()

void EcalMipGraphs::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 98 of file EcalMipGraphs.cc.

References edm::SortedCollection< T, SORT >::begin(), caloTopo_, canvasNames_, EBdigisHandle, ebDigiToken_, ebRecHitToken_, EEdigisHandle, eeDigiToken_, eeRecHitToken_, edm::SortedCollection< T, SORT >::end(), FEDsAndDCCHeaders_, fileService, edm::EventSetup::getData(), iEvent, listEBChannels, listEEChannels, TFileService::make(), naiveEvtNum_, names, rawDataToken_, runNum_, selectHits(), and topologyToken_.

98  {
99  // get the headers
100  // (one header for each supermodule)
102  iEvent.getByToken(rawDataToken_, DCCHeaders);
103 
104  for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
105  ++headerItr) {
106  FEDsAndDCCHeaders_[headerItr->id() + 600] = *headerItr;
107  }
108 
109  int ievt = iEvent.id().event();
110  naiveEvtNum_++;
111 
112  if (runNum_ == -1) {
113  runNum_ = iEvent.id().run();
114  canvasNames_ = fileService->make<TTree>("canvasNames", "Names of written canvases");
115  names = new std::vector<string>();
116  canvasNames_->Branch("names", "vector<string>", &names);
117  }
118 
119  //We only want the 3x3's for this event...
120  listEBChannels.clear();
121  listEEChannels.clear();
122  caloTopo_ = &iSetup.getData(topologyToken_);
123 
126  iEvent.getByToken(ebRecHitToken_, EBhits);
127  iEvent.getByToken(eeRecHitToken_, EEhits);
128  // Now, retrieve the crystal digi from the event
129  iEvent.getByToken(ebDigiToken_, EBdigisHandle);
130  iEvent.getByToken(eeDigiToken_, EEdigisHandle);
131 
132  selectHits(EBhits, ievt);
133  selectHits(EEhits, ievt);
134 }
const edm::EDGetTokenT< EEDigiCollection > eeDigiToken_
Definition: EcalMipGraphs.h:92
void selectHits(edm::Handle< EcalRecHitCollection > hits, int ievt)
std::vector< T >::const_iterator const_iterator
TTree * canvasNames_
static edm::Service< TFileService > fileService
std::set< EEDetId > listEEChannels
std::map< int, EcalDCCHeaderBlock > FEDsAndDCCHeaders_
const edm::EDGetTokenT< EcalRawDataCollection > rawDataToken_
Definition: EcalMipGraphs.h:88
std::set< EBDetId > listEBChannels
int iEvent
Definition: GenABIO.cc:224
const_iterator begin() const
const_iterator end() const
const CaloTopology * caloTopo_
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHitToken_
Definition: EcalMipGraphs.h:89
edm::Handle< EEDigiCollection > EEdigisHandle
Definition: EcalMipGraphs.h:86
std::vector< std::string > * names
const edm::EDGetTokenT< EBDigiCollection > ebDigiToken_
Definition: EcalMipGraphs.h:91
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > topologyToken_
Definition: EcalMipGraphs.h:95
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHitToken_
Definition: EcalMipGraphs.h:90
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::Handle< EBDigiCollection > EBdigisHandle
Definition: EcalMipGraphs.h:85

◆ beginRun()

void EcalMipGraphs::beginRun ( edm::Run const &  ,
edm::EventSetup const &  c 
)
overrideprivate

Definition at line 332 of file EcalMipGraphs.cc.

References DummyCfis::c, ecalElectronicsMap_, and ecalMappingToken_.

332  {
334 }
const EcalElectronicsMapping * ecalElectronicsMap_
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > ecalMappingToken_
Definition: EcalMipGraphs.h:94

◆ endJob()

void EcalMipGraphs::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 339 of file EcalMipGraphs.cc.

References canvasNames_, ewkTauDQM_cfi::channels, l1tstage2emulator_dqm_sourceclient-live_cfg::feds, intToString(), maskedChannels_, maskedFEDs_, seedFrequencyMap_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by o2olib.O2ORunMgr::executeJob().

339  {
340  canvasNames_->Fill();
341 
342  string frequencies = "";
343  for (std::map<std::string, int>::const_iterator itr = seedFrequencyMap_.begin(); itr != seedFrequencyMap_.end();
344  ++itr) {
345  if (itr->second > 1) {
346  frequencies += itr->first;
347  frequencies += " Frequency: ";
348  frequencies += intToString(itr->second);
349  frequencies += "\n";
350  }
351  }
352  LogWarning("EcalMipGraphs") << "Found seeds with frequency > 1: "
353  << "\n\n"
354  << frequencies;
355 
357  for (std::vector<int>::const_iterator itr = maskedChannels_.begin(); itr != maskedChannels_.end(); ++itr) {
358  channels += intToString(*itr);
359  channels += ",";
360  }
361 
363  for (std::vector<int>::const_iterator itr = maskedFEDs_.begin(); itr != maskedFEDs_.end(); ++itr) {
364  feds += intToString(*itr);
365  feds += ",";
366  }
367 
368  LogWarning("EcalMipGraphs") << "Masked channels are: " << channels;
369  LogWarning("EcalMipGraphs") << "Masked FEDs are: " << feds << " and that is all!";
370 }
std::vector< int > maskedFEDs_
std::string intToString(int num)
TTree * canvasNames_
std::map< std::string, int > seedFrequencyMap_
std::vector< int > maskedChannels_
Log< level::Warning, false > LogWarning

◆ endRun()

void EcalMipGraphs::endRun ( edm::Run const &  ,
edm::EventSetup const &  c 
)
overrideprivate

Definition at line 336 of file EcalMipGraphs.cc.

336 {}

◆ floatToString()

std::string EcalMipGraphs::floatToString ( float  num)
private

Definition at line 379 of file EcalMipGraphs.cc.

References EgammaValidation_cff::num.

Referenced by selectDigi().

379  {
380  using namespace std;
381  ostringstream myStream;
382  myStream << num << flush;
383  return (myStream.str()); //returns the string form of the stringstream object
384 }

◆ getEEIndex()

int EcalMipGraphs::getEEIndex ( EcalElectronicsId  elecId)
private

Definition at line 314 of file EcalMipGraphs.cc.

References EcalElectronicsId::dccId(), EcalElectronicsId::stripId(), EcalElectronicsId::towerId(), and EcalElectronicsId::xtalId().

Referenced by selectDigi(), and selectHits().

314  {
315  int FEDid = 600 + elecId.dccId();
316  return 10000 * FEDid + 100 * elecId.towerId() + 5 * (elecId.stripId() - 1) + elecId.xtalId();
317 }
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
int towerId() const
get the tower id
int stripId() const
get the tower id
int xtalId() const
get the channel id

◆ initHists()

void EcalMipGraphs::initHists ( int  FED)
private

Definition at line 320 of file EcalMipGraphs.cc.

References fedMap_, FEDsAndTimingHists_, fileService, EcalFedMap::getSliceFromFed(), intToString(), and TFileService::make().

Referenced by selectHits().

320  {
321  using namespace std;
322 
323  string title1 = "Jitter for ";
324  title1.append(fedMap_->getSliceFromFed(FED));
325  string name1 = "JitterFED";
326  name1.append(intToString(FED));
327  TH1F* timingHist = fileService->make<TH1F>(name1.c_str(), title1.c_str(), 150, -7, 7);
328  FEDsAndTimingHists_[FED] = timingHist;
329 }
EcalFedMap * fedMap_
std::string intToString(int num)
static edm::Service< TFileService > fileService
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:86
std::map< int, TH1F * > FEDsAndTimingHists_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ intToString()

std::string EcalMipGraphs::intToString ( int  num)
private

Definition at line 372 of file EcalMipGraphs.cc.

References EgammaValidation_cff::num.

Referenced by endJob(), initHists(), selectDigi(), and selectHits().

372  {
373  using namespace std;
374  ostringstream myStream;
375  myStream << num << flush;
376  return (myStream.str()); //returns the string form of the stringstream object
377 }

◆ selectDigi()

TGraph * EcalMipGraphs::selectDigi ( DetId  det,
int  ievt 
)
private

Definition at line 136 of file EcalMipGraphs.cc.

References abscissa, edm::DataFrameContainer::begin(), crysAndAmplitudesMap_, EcalElectronicsId::dccId(), DetId::det(), das-up-to-nevents::df, EBdigisHandle, DetId::Ecal, ecalElectronicsMap_, EEdigisHandle, edm::DataFrameContainer::end(), hcalRecHitTable_cff::energy, fedMap_, FEDsAndDCCHeaders_, fileService, nano_mu_digi_cff::float, floatToString(), ecalLiteDTU::gainId(), gainRatio, getEEIndex(), EcalElectronicsMapping::getElectronicsId(), EcalFedMap::getSliceFromFed(), mps_fire::i, intToString(), PixelPluginsPhase0_cfi::isBarrel, TFileService::make(), naiveEvtNum_, Skims_PA_cff::name, ordinate, EcalCondDBWriter_cfi::pedestal, and runGCPTkAlMap::title.

Referenced by selectHits().

136  {
137  int emptyY[10];
138  for (int i = 0; i < 10; i++)
139  emptyY[i] = 0;
140  TGraph* emptyGraph = fileService->make<TGraph>(10, abscissa, emptyY);
141  emptyGraph->SetTitle("NOT ECAL");
142 
143  //If the DetId is not from Ecal, return
144  if (thisDet.det() != DetId::Ecal)
145  return emptyGraph;
146 
147  emptyGraph->SetTitle("NO DIGIS");
148  //find digi we need -- can't get find() to work; need DataFrame(DetId det) to work?
150  int FEDid = 600 + elecId.dccId();
151  bool isBarrel = true;
152  if (FEDid < 610 || FEDid > 645)
153  isBarrel = false;
154  int cryIndex = isBarrel ? ((EBDetId)thisDet).hashedIndex() : getEEIndex(elecId);
155  int ic = isBarrel ? ((EBDetId)thisDet).ic() : cryIndex;
156 
157  string sliceName = fedMap_->getSliceFromFed(FEDid);
159  if (isBarrel) {
161  while (digiItr != EBdigisHandle->end() && ((*digiItr).id() != (EBDetId)thisDet)) {
162  ++digiItr;
163  }
164  if (digiItr == EBdigisHandle->end()) {
165  //LogWarning("EcalMipGraphs") << "Cannot find digi for ic:" << ic
166  // << " FED:" << FEDid << " evt:" << naiveEvtNum_;
167  return emptyGraph;
168  } else
169  df = *digiItr;
170  } else {
172  while (digiItr != EEdigisHandle->end() && ((*digiItr).id() != (EEDetId)thisDet)) {
173  ++digiItr;
174  }
175  if (digiItr == EEdigisHandle->end()) {
176  //LogWarning("EcalMipGraphs") << "Cannot find digi for ic:" << ic
177  // << " FED:" << FEDid << " evt:" << naiveEvtNum_;
178  return emptyGraph;
179  } else
180  df = *digiItr;
181  }
182 
183  int gainId = FEDsAndDCCHeaders_[FEDid].getMgpaGain();
184  int gainHuman;
185  if (gainId == 1)
186  gainHuman = 12;
187  else if (gainId == 2)
188  gainHuman = 6;
189  else if (gainId == 3)
190  gainHuman = 1;
191  else
192  gainHuman = -1;
193 
194  double pedestal = 200;
195 
196  emptyGraph->SetTitle("FIRST TWO SAMPLES NOT GAIN12");
197  if (df.sample(0).gainId() != 1 || df.sample(1).gainId() != 1)
198  return emptyGraph; //goes to the next digi
199  else {
200  ordinate[0] = df.sample(0).adc();
201  ordinate[1] = df.sample(1).adc();
202  pedestal = (double)(ordinate[0] + ordinate[1]) / (double)2;
203  }
204 
205  for (int i = 0; i < df.size(); ++i) {
206  if (df.sample(i).gainId() != 0)
207  ordinate[i] = (int)(pedestal + (df.sample(i).adc() - pedestal) * gainRatio[df.sample(i).gainId() - 1]);
208  else
209  ordinate[i] = 49152; //Saturation of gain1
210  }
211 
212  TGraph* oneGraph = fileService->make<TGraph>(10, abscissa, ordinate);
213  string name = "Graph_ev" + intToString(naiveEvtNum_) + "_ic" + intToString(ic) + "_FED" + intToString(FEDid);
214  string gainString = (gainId == 1) ? "Free" : intToString(gainHuman);
215  string title = "Event" + intToString(naiveEvtNum_) + "_lv1a" + intToString(ievt) + "_ic" + intToString(ic) + "_" +
216  sliceName + "_gain" + gainString;
217 
218  float energy = 0;
219  map<int, float>::const_iterator itr;
220  itr = crysAndAmplitudesMap_.find(cryIndex);
221  if (itr != crysAndAmplitudesMap_.end()) {
222  //edm::LogWarning("EcalMipGraphs")<< "itr->second(ampli)="<< itr->second;
223  energy = (float)itr->second;
224  }
225  //else
226  //edm::LogWarning("EcalMipGraphs") << "cry " << ic << "not found in ampMap";
227 
228  title += "_Energy" + floatToString(round(energy * 1000));
229 
230  oneGraph->SetTitle(title.c_str());
231  oneGraph->SetName(name.c_str());
232  oneGraph->GetXaxis()->SetTitle("sample");
233  oneGraph->GetYaxis()->SetTitle("ADC");
234  return oneGraph;
235 }
std::string floatToString(float num)
int getEEIndex(EcalElectronicsId elecId)
EcalFedMap * fedMap_
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
std::string intToString(int num)
const EcalElectronicsMapping * ecalElectronicsMap_
static edm::Service< TFileService > fileService
int abscissa[10]
std::map< int, EcalDCCHeaderBlock > FEDsAndDCCHeaders_
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:86
std::map< int, float > crysAndAmplitudesMap_
int ordinate[10]
const_iterator end() const
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
edm::Handle< EEDigiCollection > EEdigisHandle
Definition: EcalMipGraphs.h:86
const_iterator begin() const
The iterator returned can not safely be used across threads.
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
static float gainRatio[3]
edm::Handle< EBDigiCollection > EBdigisHandle
Definition: EcalMipGraphs.h:85

◆ selectHits()

void EcalMipGraphs::selectHits ( edm::Handle< EcalRecHitCollection hits,
int  ievt 
)
private

Definition at line 237 of file EcalMipGraphs.cc.

References allFedsTimingHist_, caloTopo_, timingPdfMaker::can, crysAndAmplitudesMap_, EcalElectronicsId::dccId(), ecalElectronicsMap_, FEDsAndTimingHists_, spr::find(), getEEIndex(), EcalElectronicsMapping::getElectronicsId(), CaloTopology::getSubdetectorTopology(), hfClusterShapes_cfi::hits, CaloNavigator< T, TOPO >::home(), mps_fire::i, hit::id, initHists(), intToString(), PixelPluginsPhase0_cfi::isBarrel, dqmiolumiharvest::j, maskedChannels_, maskedFEDs_, minTimingAmp_, naiveEvtNum_, Skims_PA_cff::name, names, CaloNavigator< T, TOPO >::offsetBy(), mps_fire::result, fileCollector::seed, seedCrys_, seedFrequencyMap_, selectDigi(), side_, threshold_, and runGCPTkAlMap::title.

Referenced by analyze().

237  {
238  for (EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr) {
239  EcalRecHit hit = (*hitItr);
240  DetId det = hit.id();
242  int FEDid = 600 + elecId.dccId();
243  bool isBarrel = true;
244  if (FEDid < 610 || FEDid > 645)
245  isBarrel = false;
246  int cryIndex = isBarrel ? ((EBDetId)det).hashedIndex() : ((EEDetId)det).hashedIndex();
247  int ic = isBarrel ? ((EBDetId)det).ic() : getEEIndex(elecId);
248 
249  float ampli = hit.energy();
250 
251  vector<int>::iterator result;
252  result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
253  if (result != maskedFEDs_.end()) {
254  //LogWarning("EcalMipGraphs") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
255  continue;
256  }
257  result = find(maskedChannels_.begin(), maskedChannels_.end(), cryIndex);
258  if (result != maskedChannels_.end()) {
259  //LogWarning("EcalMipGraphs") << "skipping uncalRecHit for channel: " << cryIndex << " in fed: " << FEDid << " with amplitude " << ampli ;
260  continue;
261  }
262  bool cryIsInList = false;
263  result = find(seedCrys_.begin(), seedCrys_.end(), cryIndex);
264  if (result != seedCrys_.end())
265  cryIsInList = true;
266 
267  // Either we must have a user-requested cry (in which case there is no amplitude selection)
268  // Or we pick all crys that pass the amplitude cut (in which case there is no fixed crystal selection)
269  if (cryIsInList || (seedCrys_.empty() && ampli > threshold_)) {
270  // We have a winner!
271  crysAndAmplitudesMap_[cryIndex] = ampli;
272  string name = "Event" + intToString(naiveEvtNum_) + "_ic" + intToString(ic) + "_FED" + intToString(FEDid);
273  string title = "Digis";
274  string seed = "ic" + intToString(ic) + "_FED" + intToString(FEDid);
275  int freq = 1;
276  pair<map<string, int>::iterator, bool> pair = seedFrequencyMap_.insert(make_pair(seed, freq));
277  if (!pair.second) {
278  ++(pair.first->second);
279  }
280 
281  TCanvas can(name.c_str(), title.c_str(), 200, 50, 900, 900);
282  can.Divide(side_, side_);
283  TGraph* myGraph;
284  int canvasNum = 1;
285 
287  //Now put each graph in one by one
288  for (int j = side_ / 2; j >= -side_ / 2; --j) {
289  for (int i = -side_ / 2; i <= side_ / 2; ++i) {
290  cursor.home();
291  cursor.offsetBy(i, j);
292  can.cd(canvasNum);
293  myGraph = selectDigi(*cursor, ievt);
294  myGraph->Draw("A*");
295  canvasNum++;
296  }
297  }
298  can.Write();
299  names->push_back(name);
300  }
301 
302  TH1F* timingHist = FEDsAndTimingHists_[FEDid];
303  if (timingHist == nullptr) {
304  initHists(FEDid);
305  timingHist = FEDsAndTimingHists_[FEDid];
306  }
307  if (ampli > minTimingAmp_) {
308  timingHist->Fill(hit.time());
309  allFedsTimingHist_->Fill(hit.time());
310  }
311  }
312 }
void home() const
move the navigator back to the starting point
Definition: CaloNavigator.h:96
std::vector< int > maskedFEDs_
int getEEIndex(EcalElectronicsId elecId)
void initHists(int)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
std::vector< EcalRecHit >::const_iterator const_iterator
std::string intToString(int num)
const EcalElectronicsMapping * ecalElectronicsMap_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< std::string, int > seedFrequencyMap_
const int side_
Definition: EcalMipGraphs.h:98
std::map< int, float > crysAndAmplitudesMap_
TGraph * selectDigi(DetId det, int ievt)
unsigned int id
const double threshold_
Definition: EcalMipGraphs.h:99
const CaloTopology * caloTopo_
Definition: DetId.h:17
std::vector< int > seedCrys_
std::vector< int > maskedChannels_
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
std::vector< std::string > * names
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Definition: CaloNavigator.h:66
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
std::map< int, TH1F * > FEDsAndTimingHists_
const double minTimingAmp_
TH1F * allFedsTimingHist_

◆ writeGraphs()

void EcalMipGraphs::writeGraphs ( )
private

Member Data Documentation

◆ abscissa

int EcalMipGraphs::abscissa[10]
private

Definition at line 105 of file EcalMipGraphs.h.

Referenced by EcalMipGraphs(), and selectDigi().

◆ allFedsTimingHist_

TH1F* EcalMipGraphs::allFedsTimingHist_
private

Definition at line 121 of file EcalMipGraphs.h.

Referenced by EcalMipGraphs(), and selectHits().

◆ caloTopo_

const CaloTopology* EcalMipGraphs::caloTopo_
private

Definition at line 127 of file EcalMipGraphs.h.

Referenced by analyze(), and selectHits().

◆ canvasNames_

TTree* EcalMipGraphs::canvasNames_
private

Definition at line 124 of file EcalMipGraphs.h.

Referenced by analyze(), and endJob().

◆ crysAndAmplitudesMap_

std::map<int, float> EcalMipGraphs::crysAndAmplitudesMap_
private

Definition at line 117 of file EcalMipGraphs.h.

Referenced by selectDigi(), and selectHits().

◆ EBDigis_

const edm::InputTag EcalMipGraphs::EBDigis_
private

Definition at line 81 of file EcalMipGraphs.h.

◆ EBdigisHandle

edm::Handle<EBDigiCollection> EcalMipGraphs::EBdigisHandle
private

Definition at line 85 of file EcalMipGraphs.h.

Referenced by analyze(), and selectDigi().

◆ ebDigiToken_

const edm::EDGetTokenT<EBDigiCollection> EcalMipGraphs::ebDigiToken_
private

Definition at line 91 of file EcalMipGraphs.h.

Referenced by analyze().

◆ EBRecHitCollection_

const edm::InputTag EcalMipGraphs::EBRecHitCollection_
private

Definition at line 79 of file EcalMipGraphs.h.

◆ ebRecHitToken_

const edm::EDGetTokenT<EcalRecHitCollection> EcalMipGraphs::ebRecHitToken_
private

Definition at line 89 of file EcalMipGraphs.h.

Referenced by analyze().

◆ ecalElectronicsMap_

const EcalElectronicsMapping* EcalMipGraphs::ecalElectronicsMap_
private

Definition at line 126 of file EcalMipGraphs.h.

Referenced by beginRun(), selectDigi(), and selectHits().

◆ ecalMappingToken_

const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> EcalMipGraphs::ecalMappingToken_
private

Definition at line 94 of file EcalMipGraphs.h.

Referenced by beginRun().

◆ EEDigis_

const edm::InputTag EcalMipGraphs::EEDigis_
private

Definition at line 82 of file EcalMipGraphs.h.

◆ EEdigisHandle

edm::Handle<EEDigiCollection> EcalMipGraphs::EEdigisHandle
private

Definition at line 86 of file EcalMipGraphs.h.

Referenced by analyze(), and selectDigi().

◆ eeDigiToken_

const edm::EDGetTokenT<EEDigiCollection> EcalMipGraphs::eeDigiToken_
private

Definition at line 92 of file EcalMipGraphs.h.

Referenced by analyze().

◆ EERecHitCollection_

const edm::InputTag EcalMipGraphs::EERecHitCollection_
private

Definition at line 80 of file EcalMipGraphs.h.

◆ eeRecHitToken_

const edm::EDGetTokenT<EcalRecHitCollection> EcalMipGraphs::eeRecHitToken_
private

Definition at line 90 of file EcalMipGraphs.h.

Referenced by analyze().

◆ fedMap_

EcalFedMap* EcalMipGraphs::fedMap_
private

Definition at line 125 of file EcalMipGraphs.h.

Referenced by EcalMipGraphs(), initHists(), and selectDigi().

◆ FEDsAndDCCHeaders_

std::map<int, EcalDCCHeaderBlock> EcalMipGraphs::FEDsAndDCCHeaders_
private

Definition at line 118 of file EcalMipGraphs.h.

Referenced by analyze(), and selectDigi().

◆ FEDsAndTimingHists_

std::map<int, TH1F*> EcalMipGraphs::FEDsAndTimingHists_
private

Definition at line 116 of file EcalMipGraphs.h.

Referenced by initHists(), and selectHits().

◆ file_

TFile* EcalMipGraphs::file_
private

Definition at line 123 of file EcalMipGraphs.h.

◆ fileService

edm::Service< TFileService > EcalMipGraphs::fileService
staticprivate

Definition at line 109 of file EcalMipGraphs.h.

Referenced by analyze(), EcalMipGraphs(), initHists(), and selectDigi().

◆ gainRatio

float EcalMipGraphs::gainRatio = {1., 2., 12.}
staticprivate

Definition at line 108 of file EcalMipGraphs.h.

Referenced by selectDigi().

◆ headerProducer_

const edm::InputTag EcalMipGraphs::headerProducer_
private

Definition at line 83 of file EcalMipGraphs.h.

◆ listEBChannels

std::set<EBDetId> EcalMipGraphs::listEBChannels
private

Definition at line 102 of file EcalMipGraphs.h.

Referenced by analyze().

◆ listEEChannels

std::set<EEDetId> EcalMipGraphs::listEEChannels
private

Definition at line 103 of file EcalMipGraphs.h.

Referenced by analyze().

◆ maskedChannels_

std::vector<int> EcalMipGraphs::maskedChannels_
private

Definition at line 112 of file EcalMipGraphs.h.

Referenced by EcalMipGraphs(), endJob(), and selectHits().

◆ maskedEBs_

std::vector<std::string> EcalMipGraphs::maskedEBs_
private

Definition at line 115 of file EcalMipGraphs.h.

Referenced by EcalMipGraphs().

◆ maskedFEDs_

std::vector<int> EcalMipGraphs::maskedFEDs_
private

Definition at line 113 of file EcalMipGraphs.h.

Referenced by EcalMipGraphs(), endJob(), and selectHits().

◆ minTimingAmp_

const double EcalMipGraphs::minTimingAmp_
private

Definition at line 100 of file EcalMipGraphs.h.

Referenced by selectHits().

◆ naiveEvtNum_

int EcalMipGraphs::naiveEvtNum_
private

Definition at line 129 of file EcalMipGraphs.h.

Referenced by analyze(), EcalMipGraphs(), selectDigi(), and selectHits().

◆ names

std::vector<std::string>* EcalMipGraphs::names
private

Definition at line 111 of file EcalMipGraphs.h.

Referenced by analyze(), and selectHits().

◆ ordinate

int EcalMipGraphs::ordinate[10]
private

Definition at line 106 of file EcalMipGraphs.h.

Referenced by selectDigi().

◆ rawDataToken_

const edm::EDGetTokenT<EcalRawDataCollection> EcalMipGraphs::rawDataToken_
private

Definition at line 88 of file EcalMipGraphs.h.

Referenced by analyze().

◆ runNum_

int EcalMipGraphs::runNum_
private

Definition at line 97 of file EcalMipGraphs.h.

Referenced by analyze().

◆ seedCrys_

std::vector<int> EcalMipGraphs::seedCrys_
private

Definition at line 114 of file EcalMipGraphs.h.

Referenced by EcalMipGraphs(), and selectHits().

◆ seedFrequencyMap_

std::map<std::string, int> EcalMipGraphs::seedFrequencyMap_
private

Definition at line 119 of file EcalMipGraphs.h.

Referenced by endJob(), and selectHits().

◆ side_

const int EcalMipGraphs::side_
private

Definition at line 98 of file EcalMipGraphs.h.

Referenced by selectHits().

◆ threshold_

const double EcalMipGraphs::threshold_
private

Definition at line 99 of file EcalMipGraphs.h.

Referenced by selectHits().

◆ topologyToken_

const edm::ESGetToken<CaloTopology, CaloTopologyRecord> EcalMipGraphs::topologyToken_
private

Definition at line 95 of file EcalMipGraphs.h.

Referenced by analyze().