CMS 3D CMS Logo

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