CMS 3D CMS Logo

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

calculate the best DAC value to obtain a pedestal = 200 More...

#include <testChannel.h>

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

Public Member Functions

void analyze (edm::Event const &event, edm::EventSetup const &eventSetup) override
 ! Analyze More...
 
void beginJob () override
 BeginJob. More...
 
void endJob (void) override
 EndJob. More...
 
void subscribe (void)
 Subscribe/Unsubscribe to Monitoring Elements. More...
 
void subscribeNew (void)
 
 testChannel (const edm::ParameterSet &ps)
 Constructor. More...
 
void unsubscribe (void)
 
 ~testChannel () override
 Destructor. More...
 
- 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
 
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

int getHeaderSMId (const int headerId)
 

Private Attributes

const int m_bestPed
 
const int m_DACmax
 
const int m_DACmin
 name of the xml file to be saved More...
 
const edm::EDGetTokenT< EBDigiCollectionm_digiProducerToken
 
const edm::EDGetTokenT< EcalRawDataCollectionm_headerProducerToken
 Token to access digis. More...
 
TH2F m_pedVSDAC
 
const double m_RMSmax
 
TH2F m_singlePedVSDAC_1
 
TH2F m_singlePedVSDAC_2
 
TH2F m_singlePedVSDAC_3
 
const std::string m_xmlFile
 Token to access headers. More...
 
const int m_xtal
 

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

calculate the best DAC value to obtain a pedestal = 200

Author
P. Govoni (testC.nosp@m.hann.nosp@m.el.go.nosp@m.voni.nosp@m.@cern.nosp@m.NOSP.nosp@m.AM.ch)

Definition at line 36 of file testChannel.h.

Constructor & Destructor Documentation

◆ testChannel()

testChannel::testChannel ( const edm::ParameterSet ps)

Constructor.

ctor

Definition at line 17 of file testChannel.cc.

References m_bestPed, m_DACmax, m_DACmin, and m_RMSmax.

19  consumes<EBDigiCollection>(edm::InputTag(paramSet.getParameter<std::string>("digiProducer")))),
21  consumes<EcalRawDataCollection>(edm::InputTag(paramSet.getParameter<std::string>("headerProducer")))),
22  m_xmlFile(paramSet.getParameter<std::string>("xmlFile")),
23  m_DACmin(paramSet.getParameter<int>("DACmin")),
24  m_DACmax(paramSet.getParameter<int>("DACmax")),
25  m_RMSmax(paramSet.getParameter<double>("RMSmax")),
26  m_bestPed(paramSet.getParameter<int>("bestPed")),
27  m_xtal(paramSet.getParameter<int>("xtal")),
28  m_pedVSDAC("pedVSDAC", "pedVSDAC", 100, 150, 250, m_DACmax - m_DACmin, m_DACmin, m_DACmax),
29  m_singlePedVSDAC_1("singlePedVSDAC_1",
30  "pedVSDAC (g1) for xtal " + TString(m_xtal),
31  100,
32  150,
33  250,
35  m_DACmin,
36  m_DACmax),
37  m_singlePedVSDAC_2("singlePedVSDAC_2",
38  "pedVSDAC (g2) for xtal " + TString(m_xtal),
39  100,
40  150,
41  250,
43  m_DACmin,
44  m_DACmax),
45  m_singlePedVSDAC_3("singlePedVSDAC_3",
46  "pedVSDAC (g3) for xtal " + TString(m_xtal),
47  100,
48  150,
49  250,
51  m_DACmin,
52  m_DACmax) {
53  edm::LogInfo("testChannel") << " reading "
54  << " m_DACmin: " << m_DACmin << " m_DACmax: " << m_DACmax << " m_RMSmax: " << m_RMSmax
55  << " m_bestPed: " << m_bestPed;
56 }
const int m_bestPed
Definition: testChannel.h:69
TH2F m_pedVSDAC
Definition: testChannel.h:73
const double m_RMSmax
Definition: testChannel.h:68
TH2F m_singlePedVSDAC_3
Definition: testChannel.h:76
TH2F m_singlePedVSDAC_1
Definition: testChannel.h:74
const int m_DACmin
name of the xml file to be saved
Definition: testChannel.h:66
Log< level::Info, false > LogInfo
const int m_DACmax
Definition: testChannel.h:67
const edm::EDGetTokenT< EBDigiCollection > m_digiProducerToken
Definition: testChannel.h:61
const int m_xtal
Definition: testChannel.h:71
TH2F m_singlePedVSDAC_2
Definition: testChannel.h:75
const edm::EDGetTokenT< EcalRawDataCollection > m_headerProducerToken
Token to access digis.
Definition: testChannel.h:62
const std::string m_xmlFile
Token to access headers.
Definition: testChannel.h:64

◆ ~testChannel()

testChannel::~testChannel ( )
override

Destructor.

dtor

Definition at line 59 of file testChannel.cc.

59 {}

Member Function Documentation

◆ analyze()

void testChannel::analyze ( edm::Event const &  event,
edm::EventSetup const &  eventSetup 
)
overridevirtual

! Analyze

perform te analysis

loop over the headers

Implements edm::one::EDAnalyzerBase.

Definition at line 65 of file testChannel.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::DataFrameContainer::begin(), hgcalPerformanceValidation::df, edm::SortedCollection< T, SORT >::end(), edm::DataFrameContainer::end(), ecalLiteDTU::gainId(), getHeaderSMId(), ecalpyutils::ism(), edm::HandleBase::isValid(), LogDebug, m_digiProducerToken, m_headerProducerToken, m_pedVSDAC, m_singlePedVSDAC_1, m_singlePedVSDAC_2, m_singlePedVSDAC_3, m_xtal, EcalDataFrame::MAXSAMPLES, and EcalDCCHeaderBlock::EcalDCCEventSettings::ped_offset.

65  {
66  LogDebug("testChannel") << "entering analyze ...";
67 
68  // get the headers
69  // (one header for each supermodule)
70  const edm::Handle<EcalRawDataCollection> &DCCHeaders = event.getHandle(m_headerProducerToken);
71  if (!DCCHeaders.isValid()) {
72  edm::LogError("testChannel") << "Error! can't get the product for EcalRawDataCollection";
73  }
74 
75  std::map<int, int> DACvalues;
76 
77  // loop over the headers
78  for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
79  ++headerItr) {
80  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
81  DACvalues[getHeaderSMId(headerItr->id())] = settings.ped_offset;
82  // std::cout << "DCCid: " << headerItr->id () << "" ;
83  // std::cout << "Ped offset DAC: " << settings.ped_offset << "" ;
84  }
85 
86  // get the digis
87  // (one digi for each crystal)
88  const edm::Handle<EBDigiCollection> &pDigis = event.getHandle(m_digiProducerToken);
89  if (!pDigis.isValid()) {
90  edm::LogError("testChannel") << "Error! can't get the product for EBDigiCollection";
91  }
92 
93  // loop over the digis
94  for (EBDigiCollection::const_iterator itdigi = pDigis->begin(); itdigi != pDigis->end(); ++itdigi) {
95  EBDataFrame df(*itdigi);
96  int gainId = df.sample(0).gainId();
97  int crystalId = EBDetId(itdigi->id()).ic();
98  int smId = EBDetId(itdigi->id()).ism();
99 
100  edm::LogInfo("testChannel") << "channel " << event.id() << "\tcry: " << crystalId << "\tG: " << gainId
101  << "\tDAC: " << DACvalues[smId];
102 
103  // loop over the samples
104  for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES; ++iSample) {
105  edm::LogInfo("testChannel") << "\t`-->" << df.sample(iSample).adc();
106  m_pedVSDAC.Fill(df.sample(iSample).adc(), DACvalues[smId]);
107  if (crystalId == m_xtal) {
108  if (gainId == 1)
109  m_singlePedVSDAC_1.Fill(df.sample(iSample).adc(), DACvalues[smId]);
110  if (gainId == 2)
111  m_singlePedVSDAC_2.Fill(df.sample(iSample).adc(), DACvalues[smId]);
112  if (gainId == 3)
113  m_singlePedVSDAC_3.Fill(df.sample(iSample).adc(), DACvalues[smId]);
114  }
115  } // loop over the samples
116  } // loop over the digis
117 }
std::vector< T >::const_iterator const_iterator
TH2F m_pedVSDAC
Definition: testChannel.h:73
Log< level::Error, false > LogError
int getHeaderSMId(const int headerId)
Definition: testChannel.cc:144
TH2F m_singlePedVSDAC_3
Definition: testChannel.h:76
TH2F m_singlePedVSDAC_1
Definition: testChannel.h:74
const_iterator begin() const
const_iterator end() const
const_iterator end() const
Log< level::Info, false > LogInfo
const edm::EDGetTokenT< EBDigiCollection > m_digiProducerToken
Definition: testChannel.h:61
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
const_iterator begin() const
The iterator returned can not safely be used across threads.
const int m_xtal
Definition: testChannel.h:71
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
bool isValid() const
Definition: HandleBase.h:70
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:49
TH2F m_singlePedVSDAC_2
Definition: testChannel.h:75
const edm::EDGetTokenT< EcalRawDataCollection > m_headerProducerToken
Token to access digis.
Definition: testChannel.h:62
#define LogDebug(id)

◆ beginJob()

void testChannel::beginJob ( )
overridevirtual

BeginJob.

begin the job

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 62 of file testChannel.cc.

References LogDebug.

62 { LogDebug("testChannel") << "entering beginJob ..."; }
#define LogDebug(id)

◆ endJob()

void testChannel::endJob ( void  )
overridevirtual

EndJob.

perform the minimiation and write results

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 120 of file testChannel.cc.

References m_pedVSDAC, m_singlePedVSDAC_1, m_singlePedVSDAC_2, m_singlePedVSDAC_3, m_xtal, and MillePedeFileConverter_cfg::out.

Referenced by o2olib.O2ORunMgr::executeJob().

120  {
121  char ccout[80];
122  sprintf(ccout, "out_%d.root", m_xtal);
123  TFile out(ccout, "RECREATE");
124  out.cd();
125  m_pedVSDAC.Write();
126  m_singlePedVSDAC_1.Write();
127  m_singlePedVSDAC_2.Write();
128  m_singlePedVSDAC_3.Write();
129  TProfile *profilo1 = m_singlePedVSDAC_1.ProfileX();
130  TProfile *profilo2 = m_singlePedVSDAC_2.ProfileX();
131  TProfile *profilo3 = m_singlePedVSDAC_3.ProfileX();
132  profilo1->Write("singleProfile_1");
133  profilo2->Write("singleProfile_2");
134  profilo3->Write("singleProfile_3");
135  out.Close();
136 }
TH2F m_pedVSDAC
Definition: testChannel.h:73
TH2F m_singlePedVSDAC_3
Definition: testChannel.h:76
TH2F m_singlePedVSDAC_1
Definition: testChannel.h:74
const int m_xtal
Definition: testChannel.h:71
TH2F m_singlePedVSDAC_2
Definition: testChannel.h:75

◆ getHeaderSMId()

int testChannel::getHeaderSMId ( const int  headerId)
private

Definition at line 144 of file testChannel.cc.

Referenced by analyze().

144  {
145  // PG FIXME temporary solution
146  // PG FIXME check it is consistent with the TB!
147  return 1;
148 }

◆ subscribe()

void testChannel::subscribe ( void  )

Subscribe/Unsubscribe to Monitoring Elements.

Definition at line 150 of file testChannel.cc.

150 {}

◆ subscribeNew()

void testChannel::subscribeNew ( void  )

Definition at line 152 of file testChannel.cc.

152 {}

◆ unsubscribe()

void testChannel::unsubscribe ( void  )

Definition at line 154 of file testChannel.cc.

154 {}

Member Data Documentation

◆ m_bestPed

const int testChannel::m_bestPed
private

Definition at line 69 of file testChannel.h.

Referenced by testChannel().

◆ m_DACmax

const int testChannel::m_DACmax
private

Definition at line 67 of file testChannel.h.

Referenced by testChannel().

◆ m_DACmin

const int testChannel::m_DACmin
private

name of the xml file to be saved

Definition at line 66 of file testChannel.h.

Referenced by testChannel().

◆ m_digiProducerToken

const edm::EDGetTokenT<EBDigiCollection> testChannel::m_digiProducerToken
private

Definition at line 61 of file testChannel.h.

Referenced by analyze().

◆ m_headerProducerToken

const edm::EDGetTokenT<EcalRawDataCollection> testChannel::m_headerProducerToken
private

Token to access digis.

Definition at line 62 of file testChannel.h.

Referenced by analyze().

◆ m_pedVSDAC

TH2F testChannel::m_pedVSDAC
private

Definition at line 73 of file testChannel.h.

Referenced by analyze(), and endJob().

◆ m_RMSmax

const double testChannel::m_RMSmax
private

Definition at line 68 of file testChannel.h.

Referenced by testChannel().

◆ m_singlePedVSDAC_1

TH2F testChannel::m_singlePedVSDAC_1
private

Definition at line 74 of file testChannel.h.

Referenced by analyze(), and endJob().

◆ m_singlePedVSDAC_2

TH2F testChannel::m_singlePedVSDAC_2
private

Definition at line 75 of file testChannel.h.

Referenced by analyze(), and endJob().

◆ m_singlePedVSDAC_3

TH2F testChannel::m_singlePedVSDAC_3
private

Definition at line 76 of file testChannel.h.

Referenced by analyze(), and endJob().

◆ m_xmlFile

const std::string testChannel::m_xmlFile
private

Token to access headers.

Definition at line 64 of file testChannel.h.

◆ m_xtal

const int testChannel::m_xtal
private

Definition at line 71 of file testChannel.h.

Referenced by analyze(), and endJob().