CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBPedestalOnlineTask.cc
Go to the documentation of this file.
1 /*
2  * \file EBPedestalOnlineTask.cc
3  *
4  * $Date: 2012/06/28 12:14:29 $
5  * $Revision: 1.51 $
6  * \author G. Della Ricca
7  *
8 */
9 
10 #include <iostream>
11 #include <fstream>
12 
15 
17 
19 
23 
25 
27 
29 
30  init_ = false;
31 
33 
34  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
35 
36  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
37 
38  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
39 
40  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
41 
42  EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
43 
44  for (int i = 0; i < 36; i++) {
45  mePedMapG12_[i] = 0;
46  }
47 
48 }
49 
51 
52 }
53 
55 
56  ievt_ = 0;
57 
58  if ( dqmStore_ ) {
59  dqmStore_->setCurrentFolder(prefixME_ + "/EBPedestalOnlineTask");
60  dqmStore_->rmdir(prefixME_ + "/EBPedestalOnlineTask");
61  }
62 
63 }
64 
66 
67  Numbers::initGeometry(c, false);
68 
69  if ( ! mergeRuns_ ) this->reset();
70 
71 }
72 
74 
75 }
76 
78 
79  for (int i = 0; i < 36; i++) {
80  if ( mePedMapG12_[i] ) mePedMapG12_[i]->Reset();
81  }
82 
83 }
84 
86 
87  init_ = true;
88 
91 
92  if ( dqmStore_ ) {
93  dir = prefixME_ + "/EBPedestalOnlineTask";
94  if(subfolder_.size())
95  dir += "/" + subfolder_;
96 
98 
99  dqmStore_->setCurrentFolder(dir + "/Gain12");
100  for (int i = 0; i < 36; i++) {
101  name = "EBPOT pedestal " + Numbers::sEB(i+1) + " G12";
102  mePedMapG12_[i] = dqmStore_->bookProfile2D(name, name, 85, 0., 85., 20, 0., 20., 4096, 0., 4096., "s");
103  mePedMapG12_[i]->setAxisTitle("ieta", 1);
104  mePedMapG12_[i]->setAxisTitle("iphi", 2);
105  dqmStore_->tag(mePedMapG12_[i], i+1);
106  }
107 
108  }
109 
110 }
111 
113 
114  if ( ! init_ ) return;
115 
116  if ( dqmStore_ ) {
117  std::string dir = prefixME_ + "/EBPedestalOnlineTask";
118  if(subfolder_.size())
119  dir += "/" + subfolder_;
120 
122 
123  dqmStore_->setCurrentFolder(dir + "/Gain12");
124  for ( int i = 0; i < 36; i++ ) {
125  if ( mePedMapG12_[i] ) dqmStore_->removeElement( mePedMapG12_[i]->getName() );
126  mePedMapG12_[i] = 0;
127  }
128 
129  }
130 
131  init_ = false;
132 
133 }
134 
136 
137  edm::LogInfo("EBPedestalOnlineTask") << "analyzed " << ievt_ << " events";
138 
139  if ( enableCleanup_ ) this->cleanup();
140 
141 }
142 
144 
145  if ( ! init_ ) this->setup();
146 
147  ievt_++;
148 
150 
151  if ( e.getByLabel(EBDigiCollection_, digis) ) {
152 
153  int nebd = digis->size();
154  LogDebug("EBPedestalOnlineTask") << "event " << ievt_ << " digi collection size " << nebd;
155 
156  for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
157 
158  EBDetId id = digiItr->id();
159 
160  int ic = id.ic();
161  int ie = (ic-1)/20 + 1;
162  int ip = (ic-1)%20 + 1;
163 
164  int ism = Numbers::iSM( id );
165 
166  float xie = ie - 0.5;
167  float xip = ip - 0.5;
168 
169  EBDataFrame dataframe = (*digiItr);
170 
171  int iMax(-1);
172  int maxADC(0);
173  for(int i(0); i < 10; i++){
174  if(dataframe.sample(i).gainId() != 1) break;
175  int adc(dataframe.sample(i).adc());
176  if(adc > maxADC){
177  maxADC = adc;
178  iMax = i;
179  }
180  }
181 
182  if(iMax != 5) continue;
183 
184  for (int i = 0; i < 3; i++) {
185 
186  int adc = dataframe.sample(i).adc();
187 
188  MonitorElement* mePedMap = 0;
189 
190  if ( dataframe.sample(i).gainId() == 1 ) mePedMap = mePedMapG12_[ism-1];
191  if ( dataframe.sample(i).gainId() == 2 ) mePedMap = 0;
192  if ( dataframe.sample(i).gainId() == 3 ) mePedMap = 0;
193 
194  float xval = float(adc);
195 
196  if ( mePedMap ) mePedMap->Fill(xie, xip, xval);
197 
198  }
199 
200  }
201 
202  } else {
203 
204  edm::LogWarning("EBPedestalOnlineTask") << EBDigiCollection_ << " not available";
205 
206  }
207 
208 }
209 
int adc(sample_type sample)
get the ADC sample (12 bits)
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2535
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:94
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:30
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
int gainId() const
get the gainId (2 bits)
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
void Fill(long long x)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1359
virtual ~EBPedestalOnlineTask()
Destructor.
edm::InputTag EBDigiCollection_
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
MonitorElement * mePedMapG12_[36]
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void endJob(void)
EndJob.
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:46
void beginJob(void)
BeginJob.
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:50
void cleanup(void)
Cleanup.
EBPedestalOnlineTask(const edm::ParameterSet &ps)
Constructor.
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:246
dbl *** dir
Definition: mlp_gen.cc:35
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36
int adc() const
get the ADC sample (12 bits)
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")
Definition: DQMStore.cc:1180