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 
std::string m_digiProducer
secondary name given to collection of digis
Definition: testChannel.h:62
void endJob(void) override
EndJob.
Definition: testChannel.cc:121
std::vector< T >::const_iterator const_iterator
void analyze(edm::Event const &event, edm::EventSetup const &eventSetup) override
! Analyze
Definition: testChannel.cc:64
TH2F m_pedVSDAC
Definition: testChannel.h:74
Log< level::Error, false > LogError
int getHeaderSMId(const int headerId)
Definition: testChannel.cc:145
void unsubscribe(void)
Definition: testChannel.cc:155
double m_RMSmax
Definition: testChannel.h:69
~testChannel() override
Destructor.
Definition: testChannel.cc:58
std::string m_headerProducer
name of module/plugin/producer making digis
Definition: testChannel.h:63
void beginJob() override
BeginJob.
Definition: testChannel.cc:61
TH2F m_singlePedVSDAC_3
Definition: testChannel.h:77
TH2F m_singlePedVSDAC_1
Definition: testChannel.h:75
void subscribe(void)
Subscribe/Unsubscribe to Monitoring Elements.
Definition: testChannel.cc:151
const_iterator begin() const
const_iterator end() const
int m_DACmin
name of the xml file to be saved
Definition: testChannel.h:67
const_iterator end() const
Log< level::Info, false > LogInfo
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.
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
bool isValid() const
Definition: HandleBase.h:70
std::string m_digiCollection
Definition: testChannel.h:61
testChannel(const edm::ParameterSet &ps)
Constructor.
Definition: testChannel.cc:17
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:76
void subscribeNew(void)
Definition: testChannel.cc:153
Definition: event.py:1
#define LogDebug(id)