CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EEPedestalOnlineTask.cc
Go to the documentation of this file.
1 /*
2  * \file EEPedestalOnlineTask.cc
3  *
4  * \author G. Della Ricca
5  *
6 */
7 
8 #include <iostream>
9 #include <fstream>
10 
13 
15 
17 
20 
22 
24 
26 
27  init_ = false;
28 
30 
31  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
32 
33  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
34 
35  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
36 
37  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
38 
39  EEDigiCollection_ = consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEDigiCollection"));
40 
41  for (int i = 0; i < 18; i++) {
42  mePedMapG12_[i] = 0;
43  }
44 
45 }
46 
48 
49 }
50 
52 
53  ievt_ = 0;
54 
55  if ( dqmStore_ ) {
56  dqmStore_->setCurrentFolder(prefixME_ + "/EEPedestalOnlineTask");
57  dqmStore_->rmdir(prefixME_ + "/EEPedestalOnlineTask");
58  }
59 
60 }
61 
63 
64  Numbers::initGeometry(c, false);
65 
66  if ( ! mergeRuns_ ) this->reset();
67 
68 }
69 
71 
72 }
73 
75 
76  for (int i = 0; i < 18; i++) {
77  if ( mePedMapG12_[i] ) mePedMapG12_[i]->Reset();
78  }
79 
80 }
81 
83 
84  init_ = true;
85 
88 
89  if ( dqmStore_ ) {
90  dir = prefixME_ + "/EEPedestalOnlineTask";
91  if(subfolder_.size())
92  dir += "/" + subfolder_;
93 
95 
96  dqmStore_->setCurrentFolder(dir + "/Gain12");
97  for (int i = 0; i < 18; i++) {
98  name = "EEPOT pedestal " + Numbers::sEE(i+1) + " G12";
99  mePedMapG12_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., 4096, 0., 4096., "s");
100  mePedMapG12_[i]->setAxisTitle("ix", 1);
101  if ( i+1 >= 1 && i+1 <= 9 ) mePedMapG12_[i]->setAxisTitle("101-ix", 1);
102  mePedMapG12_[i]->setAxisTitle("iy", 2);
103  dqmStore_->tag(mePedMapG12_[i], i+1);
104  }
105 
106  }
107 
108 }
109 
111 
112  if ( ! init_ ) return;
113 
114  if ( dqmStore_ ) {
115  std::string dir = prefixME_ + "/EEPedestalOnlineTask";
116  if(subfolder_.size())
117  dir += "/" + subfolder_;
118 
120 
121  dqmStore_->setCurrentFolder(dir + "/Gain12");
122  for ( int i = 0; i < 18; i++ ) {
123  if ( mePedMapG12_[i] ) dqmStore_->removeElement( mePedMapG12_[i]->getName() );
124  mePedMapG12_[i] = 0;
125  }
126 
127  }
128 
129  init_ = false;
130 
131 }
132 
134 
135  edm::LogInfo("EEPedestalOnlineTask") << "analyzed " << ievt_ << " events";
136 
137  if ( enableCleanup_ ) this->cleanup();
138 
139 }
140 
142 
143  if ( ! init_ ) this->setup();
144 
145  ievt_++;
146 
148 
149  if ( e.getByToken(EEDigiCollection_, digis) ) {
150 
151  int need = digis->size();
152  LogDebug("EEPedestalOnlineTask") << "event " << ievt_ << " digi collection size " << need;
153 
154  for ( EEDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
155 
156  EEDetId id = digiItr->id();
157 
158  int ix = id.ix();
159  int iy = id.iy();
160 
161  int ism = Numbers::iSM( id );
162 
163  if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;
164 
165  float xix = ix - 0.5;
166  float xiy = iy - 0.5;
167 
168  EEDataFrame dataframe = (*digiItr);
169 
170  int iMax(-1);
171  int maxADC(0);
172  for(int i(0); i < 10; i++){
173  if(dataframe.sample(i).gainId() != 1) break;
174  int adc(dataframe.sample(i).adc());
175  if(adc > maxADC){
176  maxADC = adc;
177  iMax = i;
178  }
179  }
180 
181  if(iMax != 5) continue;
182 
183  for (int i = 0; i < 3; i++) {
184 
185  int adc = dataframe.sample(i).adc();
186 
187  MonitorElement* mePedMap = 0;
188 
189  if ( dataframe.sample(i).gainId() == 1 ) mePedMap = mePedMapG12_[ism-1];
190  if ( dataframe.sample(i).gainId() == 2 ) mePedMap = 0;
191  if ( dataframe.sample(i).gainId() == 3 ) mePedMap = 0;
192 
193  float xval = float(adc);
194 
195  if ( mePedMap ) mePedMap->Fill(xix, xiy, xval);
196 
197  }
198 
199  }
200 
201  } else {
202 
203  edm::LogWarning("EEPedestalOnlineTask") << "EEDigiCollection not available";
204 
205  }
206 
207 }
208 
int adc(sample_type sample)
get the ADC sample (12 bits)
#define LogDebug(id)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:223
int i
Definition: DBlmapReader.cc:9
int ix() const
Definition: EEDetId.h:76
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
Some &quot;id&quot; conversions.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void cleanup(void)
Cleanup.
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
void endJob(void)
EndJob.
static int ix0EE(const unsigned ism)
Definition: Numbers.cc:770
EEPedestalOnlineTask(const edm::ParameterSet &ps)
Constructor.
int gainId() const
get the gainId (2 bits)
MonitorElement * mePedMapG12_[18]
static int iy0EE(const unsigned ism)
Definition: Numbers.cc:809
void Fill(long long x)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1509
void beginJob(void)
BeginJob.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
edm::EDGetTokenT< EEDigiCollection > EEDigiCollection_
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:47
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
virtual ~EEPedestalOnlineTask()
Destructor.
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:243
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:584
Definition: Run.h:41
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:1330