CMS 3D CMS Logo

testChannel.cc
Go to the documentation of this file.
1 
11 
12 #include "TFile.h"
13 #include "TString.h"
14 
16 
19  m_digiCollection (paramSet.getParameter<std::string> ("digiCollection")) ,
20  m_digiProducer (paramSet.getParameter<std::string> ("digiProducer")) ,
21  m_headerProducer (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","pedVSDAC (g1) for xtal "+TString(m_xtal),100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
30  m_singlePedVSDAC_2 ("singlePedVSDAC_2","pedVSDAC (g2) for xtal "+TString(m_xtal),100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
31  m_singlePedVSDAC_3 ("singlePedVSDAC_3","pedVSDAC (g3) for xtal "+TString(m_xtal),100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax)
32 {
33  edm::LogInfo ("testChannel") << " reading "
34  << " m_DACmin: " << m_DACmin
35  << " m_DACmax: " << m_DACmax
36  << " m_RMSmax: " << m_RMSmax
37  << " m_bestPed: " << m_bestPed ;
38 }
39 
40 
43 {
44 }
45 
46 
49 {
50  LogDebug ("testChannel") << "entering beginJob ..." ;
51 }
52 
53 
56  edm::EventSetup const& eventSetup)
57 {
58  LogDebug ("testChannel") << "entering analyze ..." ;
59 
60  // get the headers
61  // (one header for each supermodule)
63  event.getByLabel (m_headerProducer, DCCHeaders) ;
64  if(!DCCHeaders.isValid())
65  {
66  edm::LogError ("testChannel") << "Error! can't get the product "
67  << m_headerProducer.c_str () ;
68  }
69 
70  std::map <int,int> DACvalues ;
71 
72  // loop over the headers
73  for ( EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin () ;
74  headerItr != DCCHeaders->end () ;
75  ++headerItr )
76  {
77  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings () ;
78  DACvalues[getHeaderSMId (headerItr->id ())] = settings.ped_offset ;
79 // std::cout << "DCCid: " << headerItr->id () << "" ;
80 // std::cout << "Ped offset DAC: " << settings.ped_offset << "" ;
81  }
82 
83  // get the digis
84  // (one digi for each crystal)
86  event.getByLabel (m_digiProducer, pDigis) ;
87  if(!pDigis.isValid())
88  {
89  edm::LogError ("testChannel") << "Error! can't get the product "
90  << m_digiCollection.c_str () ;
91  }
92 
93  // loop over the digis
94  for (EBDigiCollection::const_iterator itdigi = pDigis->begin () ;
95  itdigi != pDigis->end () ;
96  ++itdigi)
97  {
98  EBDataFrame df( *itdigi );
99  int gainId = df.sample (0).gainId () ;
100  int crystalId = EBDetId(itdigi->id ()).ic () ;
101  int smId = EBDetId(itdigi->id ()).ism () ;
102 
103  edm::LogInfo ("testChannel") << "channel " << event.id ()
104  << "\tcry: " << crystalId
105  << "\tG: " << gainId
106  << "\tDAC: " << DACvalues[smId] ;
107 
108  // loop over the samples
109  for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES ; ++iSample)
110  {
111  edm::LogInfo ("testChannel") << "\t`-->" << df.sample (iSample).adc () ;
112  m_pedVSDAC.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
113  if (crystalId == m_xtal)
114  {
115  if (gainId == 1) m_singlePedVSDAC_1.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
116  if (gainId == 2) m_singlePedVSDAC_2.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
117  if (gainId == 3) m_singlePedVSDAC_3.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
118  }
119  } // loop over the samples
120  } // loop over the digis
121 
122 }
123 
126 {
127  char ccout[80] ;
128  sprintf (ccout,"out_%d.root",m_xtal) ;
129  TFile out (ccout,"RECREATE") ;
130  out.cd () ;
131  m_pedVSDAC.Write () ;
132  m_singlePedVSDAC_1.Write () ;
133  m_singlePedVSDAC_2.Write () ;
134  m_singlePedVSDAC_3.Write () ;
135  TProfile * profilo1 = m_singlePedVSDAC_1.ProfileX () ;
136  TProfile * profilo2 = m_singlePedVSDAC_2.ProfileX () ;
137  TProfile * profilo3 = m_singlePedVSDAC_3.ProfileX () ;
138  profilo1->Write ("singleProfile_1") ;
139  profilo2->Write ("singleProfile_2") ;
140  profilo3->Write ("singleProfile_3") ;
141  out.Close () ;
142 }
143 
144 /*
145 void testChannel::writeDb (EcalCondDBInterface* econn,
146  MonRunIOV* moniov)
147 {}
148 */
149 
150 int testChannel::getHeaderSMId (const int headerId)
151 {
152  //PG FIXME temporary solution
153  //PG FIXME check it is consistent with the TB!
154  return 1 ;
155 }
156 
157 
158 
159 
161 {}
162 
164 {}
165 
167 {}
168 
169 
#define LogDebug(id)
std::string m_digiProducer
secondary name given to collection of digis
Definition: testChannel.h:66
void endJob(void) override
EndJob.
Definition: testChannel.cc:125
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
int gainId(sample_type sample)
get the gainId (2 bits)
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
void analyze(edm::Event const &event, edm::EventSetup const &eventSetup) override
! Analyze
Definition: testChannel.cc:55
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
const_iterator begin() const
TH2F m_pedVSDAC
Definition: testChannel.h:78
int gainId() const
get the gainId (2 bits)
int getHeaderSMId(const int headerId)
Definition: testChannel.cc:150
void unsubscribe(void)
Definition: testChannel.cc:166
double m_RMSmax
Definition: testChannel.h:73
~testChannel() override
Destructor.
Definition: testChannel.cc:42
std::string m_headerProducer
name of module/plugin/producer making digis
Definition: testChannel.h:67
void beginJob() override
BeginJob.
Definition: testChannel.cc:48
TH2F m_singlePedVSDAC_3
Definition: testChannel.h:81
TH2F m_singlePedVSDAC_1
Definition: testChannel.h:79
void subscribe(void)
Subscribe/Unsubscribe to Monitoring Elements.
Definition: testChannel.cc:160
bool isValid() const
Definition: HandleBase.h:74
int m_DACmin
name of the xml file to be saved
Definition: testChannel.h:71
const_iterator end() const
const_iterator end() const
std::string m_digiCollection
Definition: testChannel.h:65
testChannel(const edm::ParameterSet &ps)
Constructor.
Definition: testChannel.cc:18
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
TH2F m_singlePedVSDAC_2
Definition: testChannel.h:80
void subscribeNew(void)
Definition: testChannel.cc:163
const_iterator begin() const
Definition: event.py:1
int adc() const
get the ADC sample (12 bits)