CMS 3D CMS Logo

testChannel.cc
Go to the documentation of this file.
1 
10 
11 #include "TFile.h"
12 #include "TString.h"
13 
15 
18  : m_digiCollection(paramSet.getParameter<std::string>("digiCollection")),
19  m_digiProducer(paramSet.getParameter<std::string>("digiProducer")),
20  m_headerProducer(paramSet.getParameter<std::string>("headerProducer")),
21  m_xmlFile(paramSet.getParameter<std::string>("xmlFile")),
22  m_DACmin(paramSet.getParameter<int>("DACmin")),
23  m_DACmax(paramSet.getParameter<int>("DACmax")),
24  m_RMSmax(paramSet.getParameter<double>("RMSmax")),
25  m_bestPed(paramSet.getParameter<int>("bestPed")),
26  m_xtal(paramSet.getParameter<int>("xtal")),
27  m_pedVSDAC("pedVSDAC", "pedVSDAC", 100, 150, 250, m_DACmax - m_DACmin, m_DACmin, m_DACmax),
28  m_singlePedVSDAC_1("singlePedVSDAC_1",
29  "pedVSDAC (g1) for xtal " + TString(m_xtal),
30  100,
31  150,
32  250,
33  m_DACmax - m_DACmin,
34  m_DACmin,
35  m_DACmax),
36  m_singlePedVSDAC_2("singlePedVSDAC_2",
37  "pedVSDAC (g2) for xtal " + TString(m_xtal),
38  100,
39  150,
40  250,
41  m_DACmax - m_DACmin,
42  m_DACmin,
43  m_DACmax),
44  m_singlePedVSDAC_3("singlePedVSDAC_3",
45  "pedVSDAC (g3) for xtal " + TString(m_xtal),
46  100,
47  150,
48  250,
49  m_DACmax - m_DACmin,
50  m_DACmin,
51  m_DACmax) {
52  edm::LogInfo("testChannel") << " reading "
53  << " m_DACmin: " << m_DACmin << " m_DACmax: " << m_DACmax << " m_RMSmax: " << m_RMSmax
54  << " m_bestPed: " << m_bestPed;
55 }
56 
59 
61 void testChannel::beginJob() { LogDebug("testChannel") << "entering beginJob ..."; }
62 
65  LogDebug("testChannel") << "entering analyze ...";
66 
67  // get the headers
68  // (one header for each supermodule)
70  event.getByLabel(m_headerProducer, DCCHeaders);
71  if (!DCCHeaders.isValid()) {
72  edm::LogError("testChannel") << "Error! can't get the product " << m_headerProducer.c_str();
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)
89  event.getByLabel(m_digiProducer, pDigis);
90  if (!pDigis.isValid()) {
91  edm::LogError("testChannel") << "Error! can't get the product " << m_digiCollection.c_str();
92  }
93 
94  // loop over the digis
95  for (EBDigiCollection::const_iterator itdigi = pDigis->begin(); itdigi != pDigis->end(); ++itdigi) {
96  EBDataFrame df(*itdigi);
97  int gainId = df.sample(0).gainId();
98  int crystalId = EBDetId(itdigi->id()).ic();
99  int smId = EBDetId(itdigi->id()).ism();
100 
101  edm::LogInfo("testChannel") << "channel " << event.id() << "\tcry: " << crystalId << "\tG: " << gainId
102  << "\tDAC: " << DACvalues[smId];
103 
104  // loop over the samples
105  for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES; ++iSample) {
106  edm::LogInfo("testChannel") << "\t`-->" << df.sample(iSample).adc();
107  m_pedVSDAC.Fill(df.sample(iSample).adc(), DACvalues[smId]);
108  if (crystalId == m_xtal) {
109  if (gainId == 1)
110  m_singlePedVSDAC_1.Fill(df.sample(iSample).adc(), DACvalues[smId]);
111  if (gainId == 2)
112  m_singlePedVSDAC_2.Fill(df.sample(iSample).adc(), DACvalues[smId]);
113  if (gainId == 3)
114  m_singlePedVSDAC_3.Fill(df.sample(iSample).adc(), DACvalues[smId]);
115  }
116  } // loop over the samples
117  } // loop over the digis
118 }
119 
122  char ccout[80];
123  sprintf(ccout, "out_%d.root", m_xtal);
124  TFile out(ccout, "RECREATE");
125  out.cd();
126  m_pedVSDAC.Write();
127  m_singlePedVSDAC_1.Write();
128  m_singlePedVSDAC_2.Write();
129  m_singlePedVSDAC_3.Write();
130  TProfile *profilo1 = m_singlePedVSDAC_1.ProfileX();
131  TProfile *profilo2 = m_singlePedVSDAC_2.ProfileX();
132  TProfile *profilo3 = m_singlePedVSDAC_3.ProfileX();
133  profilo1->Write("singleProfile_1");
134  profilo2->Write("singleProfile_2");
135  profilo3->Write("singleProfile_3");
136  out.Close();
137 }
138 
139 /*
140 void testChannel::writeDb (EcalCondDBInterface* econn,
141  MonRunIOV* moniov)
142 {}
143 */
144 
145 int testChannel::getHeaderSMId(const int headerId) {
146  // PG FIXME temporary solution
147  // PG FIXME check it is consistent with the TB!
148  return 1;
149 }
150 
152 
154 
EcalDataFrame::MAXSAMPLES
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
EcalDataFrame::sample
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
testChannel::m_DACmax
int m_DACmax
Definition: testChannel.h:68
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
testChannel::m_digiProducer
std::string m_digiProducer
secondary name given to collection of digis
Definition: testChannel.h:62
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
EBDetId
Definition: EBDetId.h:17
EBDataFrame
Definition: EBDataFrame.h:11
edm::LogInfo
Definition: MessageLogger.h:254
edm::Handle
Definition: AssociativeIterator.h:50
testChannel::analyze
void analyze(edm::Event const &event, edm::EventSetup const &eventSetup) override
! Analyze
Definition: testChannel.cc:64
testChannel::~testChannel
~testChannel() override
Destructor.
Definition: testChannel.cc:58
testChannel::m_headerProducer
std::string m_headerProducer
name of module/plugin/producer making digis
Definition: testChannel.h:63
EcalMGPASample::gainId
int gainId() const
get the gainId (2 bits)
Definition: EcalMGPASample.h:33
EcalRawDataCollections.h
testChannel::beginJob
void beginJob() override
BeginJob.
Definition: testChannel.cc:61
EcalMGPASample::adc
int adc() const
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:31
testChannel::m_xtal
int m_xtal
Definition: testChannel.h:72
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
testChannel::unsubscribe
void unsubscribe(void)
Definition: testChannel.cc:155
testChannel::m_pedVSDAC
TH2F m_pedVSDAC
Definition: testChannel.h:74
testChannel::getHeaderSMId
int getHeaderSMId(const int headerId)
Definition: testChannel.cc:145
testChannel::m_singlePedVSDAC_3
TH2F m_singlePedVSDAC_3
Definition: testChannel.h:77
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalDCCHeaderBlock::EcalDCCEventSettings
Definition: EcalDCCHeaderBlock.h:64
testChannel::m_RMSmax
double m_RMSmax
Definition: testChannel.h:69
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
testChannel::subscribe
void subscribe(void)
Subscribe/Unsubscribe to Monitoring Elements.
Definition: testChannel.cc:151
testChannel::m_DACmin
int m_DACmin
name of the xml file to be saved
Definition: testChannel.h:67
testChannel::m_bestPed
int m_bestPed
Definition: testChannel.h:70
createfilelist.int
int
Definition: createfilelist.py:10
edm::DataFrameContainer::begin
const_iterator begin() const
The iterator returned can not safely be used across threads.
Definition: DataFrameContainer.h:149
testChannel.h
EcalDCCHeaderBlock.h
testChannel::testChannel
testChannel(const edm::ParameterSet &ps)
Constructor.
Definition: testChannel.cc:17
testChannel::m_singlePedVSDAC_1
TH2F m_singlePedVSDAC_1
Definition: testChannel.h:75
edm::EventSetup
Definition: EventSetup.h:57
EcalDCCHeaderBlock::EcalDCCEventSettings::ped_offset
short ped_offset
Definition: EcalDCCHeaderBlock.h:71
ecalpyutils::ism
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:51
std
Definition: JetResolutionObject.h:76
testChannel::m_singlePedVSDAC_2
TH2F m_singlePedVSDAC_2
Definition: testChannel.h:76
testChannel::subscribeNew
void subscribeNew(void)
Definition: testChannel.cc:153
options_cfi.eventSetup
eventSetup
Definition: options_cfi.py:12
testChannel::m_digiCollection
std::string m_digiCollection
Definition: testChannel.h:61
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ecalMGPA::gainId
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: EcalMGPASample.h:13
testChannel::endJob
void endJob(void) override
EndJob.
Definition: testChannel.cc:121
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152