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  * \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  EBDigiCollection_ = consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBDigiCollection"));
40 
41  for (int i = 0; i < 36; i++) {
42  mePedMapG12_[i] = 0;
43  }
44 
45 }
46 
48 
49 }
50 
52 
53  ievt_ = 0;
54 
55  if ( dqmStore_ ) {
56  dqmStore_->setCurrentFolder(prefixME_ + "/EBPedestalOnlineTask");
57  dqmStore_->rmdir(prefixME_ + "/EBPedestalOnlineTask");
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 < 36; i++) {
77  if ( mePedMapG12_[i] ) mePedMapG12_[i]->Reset();
78  }
79 
80 }
81 
83 
84  init_ = true;
85 
88 
89  if ( dqmStore_ ) {
90  dir = prefixME_ + "/EBPedestalOnlineTask";
91  if(subfolder_.size())
92  dir += "/" + subfolder_;
93 
95 
96  dqmStore_->setCurrentFolder(dir + "/Gain12");
97  for (int i = 0; i < 36; i++) {
98  name = "EBPOT pedestal " + Numbers::sEB(i+1) + " G12";
99  mePedMapG12_[i] = dqmStore_->bookProfile2D(name, name, 85, 0., 85., 20, 0., 20., 4096, 0., 4096., "s");
100  mePedMapG12_[i]->setAxisTitle("ieta", 1);
101  mePedMapG12_[i]->setAxisTitle("iphi", 2);
102  dqmStore_->tag(mePedMapG12_[i], i+1);
103  }
104 
105  }
106 
107 }
108 
110 
111  if ( ! init_ ) return;
112 
113  if ( dqmStore_ ) {
114  std::string dir = prefixME_ + "/EBPedestalOnlineTask";
115  if(subfolder_.size())
116  dir += "/" + subfolder_;
117 
119 
120  dqmStore_->setCurrentFolder(dir + "/Gain12");
121  for ( int i = 0; i < 36; i++ ) {
122  if ( mePedMapG12_[i] ) dqmStore_->removeElement( mePedMapG12_[i]->getName() );
123  mePedMapG12_[i] = 0;
124  }
125 
126  }
127 
128  init_ = false;
129 
130 }
131 
133 
134  edm::LogInfo("EBPedestalOnlineTask") << "analyzed " << ievt_ << " events";
135 
136  if ( enableCleanup_ ) this->cleanup();
137 
138 }
139 
141 
142  if ( ! init_ ) this->setup();
143 
144  ievt_++;
145 
147 
148  if ( e.getByToken(EBDigiCollection_, digis) ) {
149 
150  int nebd = digis->size();
151  LogDebug("EBPedestalOnlineTask") << "event " << ievt_ << " digi collection size " << nebd;
152 
153  for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
154 
155  EBDetId id = digiItr->id();
156 
157  int ic = id.ic();
158  int ie = (ic-1)/20 + 1;
159  int ip = (ic-1)%20 + 1;
160 
161  int ism = Numbers::iSM( id );
162 
163  float xie = ie - 0.5;
164  float xip = ip - 0.5;
165 
166  EBDataFrame dataframe = (*digiItr);
167 
168  int iMax(-1);
169  int maxADC(0);
170  for(int i(0); i < 10; i++){
171  if(dataframe.sample(i).gainId() != 1) break;
172  int adc(dataframe.sample(i).adc());
173  if(adc > maxADC){
174  maxADC = adc;
175  iMax = i;
176  }
177  }
178 
179  if(iMax != 5) continue;
180 
181  for (int i = 0; i < 3; i++) {
182 
183  int adc = dataframe.sample(i).adc();
184 
185  MonitorElement* mePedMap = 0;
186 
187  if ( dataframe.sample(i).gainId() == 1 ) mePedMap = mePedMapG12_[ism-1];
188  if ( dataframe.sample(i).gainId() == 2 ) mePedMap = 0;
189  if ( dataframe.sample(i).gainId() == 3 ) mePedMap = 0;
190 
191  float xval = float(adc);
192 
193  if ( mePedMap ) mePedMap->Fill(xie, xip, xval);
194 
195  }
196 
197  }
198 
199  } else {
200 
201  edm::LogWarning("EBPedestalOnlineTask") << "EBDigiCollection not available";
202 
203  }
204 
205 }
206 
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:2730
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
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:1509
virtual ~EBPedestalOnlineTask()
Destructor.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
edm::EDGetTokenT< EBDigiCollection > EBDigiCollection_
MonitorElement * mePedMapG12_[36]
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:47
void cleanup(void)
Cleanup.
EBPedestalOnlineTask(const edm::ParameterSet &ps)
Constructor.
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