CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
testChannel.cc
Go to the documentation of this file.
1 
13 
14 #include "TFile.h"
15 
17 
20  m_digiCollection (paramSet.getParameter<std::string> ("digiCollection")) ,
21  m_digiProducer (paramSet.getParameter<std::string> ("digiProducer")) ,
22  m_headerProducer (paramSet.getParameter<std::string> ("headerProducer")) ,
23  m_xmlFile (paramSet.getParameter<std::string> ("xmlFile")) ,
24  m_DACmin (paramSet.getParameter<int> ("DACmin")) ,
25  m_DACmax (paramSet.getParameter<int> ("DACmax")) ,
26  m_RMSmax (paramSet.getParameter<double> ("RMSmax")) ,
27  m_bestPed (paramSet.getParameter<int> ("bestPed")) ,
28  m_xtal (paramSet.getParameter<int> ("xtal")) ,
29  m_pedVSDAC ("pedVSDAC","pedVSDAC",100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
30  m_singlePedVSDAC_1 ("singlePedVSDAC_1","pedVSDAC (g1) for xtal "+m_xtal,100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
31  m_singlePedVSDAC_2 ("singlePedVSDAC_2","pedVSDAC (g2) for xtal "+m_xtal,100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax) ,
32  m_singlePedVSDAC_3 ("singlePedVSDAC_3","pedVSDAC (g3) for xtal "+m_xtal,100,150,250,m_DACmax-m_DACmin,m_DACmin,m_DACmax)
33 {
34  edm::LogInfo ("testChannel") << " reading "
35  << " m_DACmin: " << m_DACmin
36  << " m_DACmax: " << m_DACmax
37  << " m_RMSmax: " << m_RMSmax
38  << " m_bestPed: " << m_bestPed ;
39 }
40 
41 
44 {
45 }
46 
47 
50 {
51  LogDebug ("testChannel") << "entering beginJob ..." ;
52 }
53 
54 
57  edm::EventSetup const& eventSetup)
58 {
59  LogDebug ("testChannel") << "entering analyze ..." ;
60 
61  // get the headers
62  // (one header for each supermodule)
64  event.getByLabel (m_headerProducer, DCCHeaders) ;
65  if(!DCCHeaders.isValid())
66  {
67  edm::LogError ("testChannel") << "Error! can't get the product "
68  << m_headerProducer.c_str () ;
69  }
70 
71  std::map <int,int> DACvalues ;
72 
73  // loop over the headers
74  for ( EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin () ;
75  headerItr != DCCHeaders->end () ;
76  ++headerItr )
77  {
78  EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings () ;
79  DACvalues[getHeaderSMId (headerItr->id ())] = settings.ped_offset ;
80 // std::cout << "DCCid: " << headerItr->id () << "" ;
81 // std::cout << "Ped offset DAC: " << settings.ped_offset << "" ;
82  }
83 
84  // get the digis
85  // (one digi for each crystal)
87  event.getByLabel (m_digiProducer, pDigis) ;
88  if(!pDigis.isValid())
89  {
90  edm::LogError ("testChannel") << "Error! can't get the product "
91  << m_digiCollection.c_str () ;
92  }
93 
94  // loop over the digis
95  for (EBDigiCollection::const_iterator itdigi = pDigis->begin () ;
96  itdigi != pDigis->end () ;
97  ++itdigi)
98  {
99  EBDataFrame df( *itdigi );
100  int gainId = df.sample (0).gainId () ;
101  int crystalId = EBDetId(itdigi->id ()).ic () ;
102  int smId = EBDetId(itdigi->id ()).ism () ;
103 
104  edm::LogInfo ("testChannel") << "channel " << event.id ()
105  << "\tcry: " << crystalId
106  << "\tG: " << gainId
107  << "\tDAC: " << DACvalues[smId] ;
108 
109  // loop over the samples
110  for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES ; ++iSample)
111  {
112  edm::LogInfo ("testChannel") << "\t`-->" << df.sample (iSample).adc () ;
113  m_pedVSDAC.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
114  if (crystalId == m_xtal)
115  {
116  if (gainId == 1) m_singlePedVSDAC_1.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
117  if (gainId == 2) m_singlePedVSDAC_2.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
118  if (gainId == 3) m_singlePedVSDAC_3.Fill (df.sample (iSample).adc (),DACvalues[smId]) ;
119  }
120  } // loop over the samples
121  } // loop over the digis
122 
123 }
124 
127 {
128  char ccout[80] ;
129  sprintf (ccout,"out_%d.root",m_xtal) ;
130  TFile out (ccout,"RECREATE") ;
131  out.cd () ;
132  m_pedVSDAC.Write () ;
133  m_singlePedVSDAC_1.Write () ;
134  m_singlePedVSDAC_2.Write () ;
135  m_singlePedVSDAC_3.Write () ;
136  TProfile * profilo1 = m_singlePedVSDAC_1.ProfileX () ;
137  TProfile * profilo2 = m_singlePedVSDAC_2.ProfileX () ;
138  TProfile * profilo3 = m_singlePedVSDAC_3.ProfileX () ;
139  profilo1->Write ("singleProfile_1") ;
140  profilo2->Write ("singleProfile_2") ;
141  profilo3->Write ("singleProfile_3") ;
142  out.Close () ;
143 }
144 
145 /*
146 void testChannel::writeDb (EcalCondDBInterface* econn,
147  MonRunIOV* moniov)
148 {}
149 */
150 
151 int testChannel::getHeaderSMId (const int headerId)
152 {
153  //PG FIXME temporary solution
154  //PG FIXME check it is consistent with the TB!
155  return 1 ;
156 }
157 
158 
159 
160 
162 {}
163 
165 {}
166 
168 {}
169 
170 
#define LogDebug(id)
std::string m_digiProducer
secondary name given to collection of digis
Definition: testChannel.h:69
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
int gainId(sample_type sample)
get the gainId (2 bits)
std::vector< T >::const_iterator const_iterator
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:28
TH2F m_pedVSDAC
Definition: testChannel.h:81
int gainId() const
get the gainId (2 bits)
int getHeaderSMId(const int headerId)
Definition: testChannel.cc:151
void unsubscribe(void)
Definition: testChannel.cc:167
double m_RMSmax
Definition: testChannel.h:76
std::string m_headerProducer
name of module/plugin/producer making digis
Definition: testChannel.h:70
void endJob(void)
EndJob.
Definition: testChannel.cc:126
TH2F m_singlePedVSDAC_3
Definition: testChannel.h:84
virtual ~testChannel()
Destructor.
Definition: testChannel.cc:43
TH2F m_singlePedVSDAC_1
Definition: testChannel.h:82
void subscribe(void)
Subscribe/Unsubscribe to Monitoring Elements.
Definition: testChannel.cc:161
void beginJob()
BeginJob.
Definition: testChannel.cc:49
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
int m_DACmin
name of the xml file to be saved
Definition: testChannel.h:74
tuple out
Definition: dbtoconf.py:99
std::string m_digiCollection
Definition: testChannel.h:68
testChannel(const edm::ParameterSet &ps)
Constructor.
Definition: testChannel.cc:19
void analyze(edm::Event const &event, edm::EventSetup const &eventSetup)
! Analyze
Definition: testChannel.cc:56
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
TH2F m_singlePedVSDAC_2
Definition: testChannel.h:83
void subscribeNew(void)
Definition: testChannel.cc:164
static const int MAXSAMPLES
Definition: EcalDataFrame.h:44
int adc() const
get the ADC sample (12 bits)