CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCClusterSizeTest.cc
Go to the documentation of this file.
3 
4 // Framework
6 
7 // //Geometry
9 
11  edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: Constructor";
12 
13  prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
14 
15  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 3);
16  numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
17  testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
18  useRollInfo_ = ps.getUntrackedParameter<bool>("useRollInfo", false);
19 
20  resetMEArrays();
21 }
22 
24 
26  edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: Begin job ";
27 
28  globalFolder_ = workingFolder;
29  dbe_ = dbe;
30 }
31 
33  edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: End run";
34 }
35 
36 void RPCClusterSizeTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector){
37 
38 
39  //Get ME for each roll
40  for (unsigned int i = 0 ; i<meVector.size(); i++){
41 
42  bool flag= false;
43 
44  DQMNet::TagList tagList;
45  tagList = meVector[i]->getTags();
46  DQMNet::TagList::iterator tagItr = tagList.begin();
47 
48  while (tagItr != tagList.end() && !flag ) {
49  if((*tagItr) == rpcdqm::CLUSTERSIZE)
50  flag= true;
51 
52  tagItr++;
53  }
54 
55  if(flag){
56  myClusterMe_.push_back(meVector[i]);
57  myDetIds_.push_back(detIdVector[i]);
58  }
59  }
60 
61 }
62 
64 
66 
68 
70 
71  edm::LogVerbatim ("rpceventsummary") <<"[RPCClusterSizeTest]:Client Operation";
72 
73  //check some statements and prescale Factor
74  if(myClusterMe_.size()==0 || myDetIds_.size()==0)return;
75 
76  MonitorElement * CLS = NULL; // ClusterSize in 1 bin, Roll vs Sector
77  MonitorElement * CLSD = NULL; // ClusterSize in 1 bin, Distribution
78  MonitorElement * MEAN = NULL; // Mean ClusterSize, Roll vs Sector
79  MonitorElement * MEAND = NULL; // Mean ClusterSize, Distribution
80 
81 
82  std::stringstream meName;
83  RPCDetId detId;
84  MonitorElement * myMe;
85 
86 
87  //Loop on chambers
88  for (unsigned int i = 0 ; i<myClusterMe_.size();i++){
89 
90  myMe = myClusterMe_[i];
91  if (!myMe || myMe->getEntries()==0 )continue;
92 
93 
94  detId=myDetIds_[i];
95 
96 
97  if (detId.region()==0){
98 
99  CLS = CLSWheel[detId.ring()+2];
100  MEAN = MEANWheel[detId.ring()+2];
101  if(testMode_){
102  CLSD = CLSDWheel[detId.ring()+2];
103  MEAND = MEANDWheel[detId.ring()+2];
104  }
105  }else {
106 
107  if(((detId.station() * detId.region() ) + numberOfDisks_) >= 0 ){
108 
109  if(detId.region()<0){
110  CLS=CLSDisk[(detId.station() * detId.region() ) + numberOfDisks_];
111  MEAN= MEANDisk[(detId.station() * detId.region() ) + numberOfDisks_];
112  if(testMode_){
113  CLSD = CLSDDisk[(detId.station() * detId.region() ) + numberOfDisks_];
114  MEAND= MEANDDisk[(detId.station() * detId.region() ) + numberOfDisks_];
115  }
116  }else{
117  CLS=CLSDisk[(detId.station() * detId.region() ) + numberOfDisks_ -1];
118  MEAN= MEANDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
119  if(testMode_){
120  CLSD = CLSDDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
121  MEAND= MEANDDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
122  }
123  }
124  }
125 
126  }
127 
128 
129  int xBin,yBin;
130 
131  if (detId.region()==0){//Barrel
132 
133  rpcdqm::utils rollNumber;
134  yBin = rollNumber.detId2RollNr(detId);
135  xBin = detId.sector();
136  }else {//Endcap
137 
138  //get segment number
139  RPCGeomServ RPCServ(detId);
140  xBin = RPCServ.segment();
141  (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
142  }
143 
144  // Normalization -> # of Entries in first Bin normalaized by total Entries
145 
146  float NormCLS = myMe->getBinContent(1)/myMe->getEntries();
147  float meanCLS = myMe->getMean();
148 
149  if (CLS) CLS -> setBinContent(xBin,yBin, NormCLS);
150  if(MEAN) MEAN -> setBinContent(xBin, yBin, meanCLS);
151 
152  if(testMode_){
153  if(MEAND) MEAND->Fill(meanCLS);
154  if(CLSD) CLSD->Fill(NormCLS);
155  }
156 
157  }//End loop on chambers
158 }
159 
161 
163  memset((void*) CLSWheel, 0, sizeof(MonitorElement*)*kWheels);
164  memset((void*) CLSDWheel, 0, sizeof(MonitorElement*)*kWheels);
165  memset((void*) MEANWheel, 0, sizeof(MonitorElement*)*kWheels);
166  memset((void*) MEANDWheel, 0, sizeof(MonitorElement*)*kWheels);
167 
168  memset((void*) CLSDisk, 0, sizeof(MonitorElement*)*kDisks);
169  memset((void*) CLSDDisk, 0, sizeof(MonitorElement*)*kDisks);
170  memset((void*) MEANDisk, 0, sizeof(MonitorElement*)*kDisks);
171  memset((void*) MEANDDisk, 0, sizeof(MonitorElement*)*kDisks);
172 }
173 
174 
176 
177  resetMEArrays();
178 
179  MonitorElement* me;
181 
182  std::stringstream histoName;
183 
184  rpcdqm::utils rpcUtils;
185 
186  // Loop over wheels
187  for (int w = -2; w <= 2; w++) {
188  histoName.str("");
189  histoName<<"ClusterSizeIn1Bin_Roll_vs_Sector_Wheel"<<w; // ClusterSize in first bin norm. by Entries (2D Roll vs Sector)
190  me = 0;
191  me = dbe_->get(globalFolder_ + histoName.str()) ;
192  if ( 0!=me ) {
193  dbe_->removeElement(me->getName());
194  }
195 
196  CLSWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
197  rpcUtils.labelXAxisSector( CLSWheel[w+2]);
198  rpcUtils.labelYAxisRoll( CLSWheel[w+2], 0, w ,useRollInfo_);
199 
200 
201  histoName.str("");
202  histoName<<"ClusterSizeMean_Roll_vs_Sector_Wheel"<<w; // Avarage ClusterSize (2D Roll vs Sector)
203  me = 0;
204  me = dbe_->get(globalFolder_ + histoName.str()) ;
205  if ( 0!=me) {
206  dbe_->removeElement(me->getName());
207  }
208 
209  MEANWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
210 
211  rpcUtils.labelXAxisSector( MEANWheel[w+2]);
212  rpcUtils.labelYAxisRoll(MEANWheel[w+2], 0, w,useRollInfo_ );
213 
214  if(testMode_){
215  histoName.str("");
216  histoName<<"ClusterSizeIn1Bin_Distribution_Wheel"<<w; // ClusterSize in first bin, distribution
217  me = 0;
218  me = dbe_->get(globalFolder_ + histoName.str()) ;
219  if ( 0!=me ) {
220  dbe_->removeElement(me->getName());
221  }
222  CLSDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, 0.0, 1.0);
223 
224 
225  histoName.str("");
226  histoName<<"ClusterSizeMean_Distribution_Wheel"<<w; // Avarage ClusterSize Distribution
227  me = 0;
228  me = dbe_->get(globalFolder_ + histoName.str()) ;
229  if ( 0!=me){
230  dbe_->removeElement(me->getName());
231  }
232  MEANDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 10.5);
233  }
234  }//end loop on wheels
235 
236 
237  for (int d = -numberOfDisks_; d <= numberOfDisks_; d++) {
238  if (d == 0)
239  continue;
240  //Endcap
241  int offset = numberOfDisks_;
242  if (d>0) offset--;
243 
244  histoName.str("");
245  histoName<<"ClusterSizeIn1Bin_Ring_vs_Segment_Disk"<<d; // ClusterSize in first bin norm. by Entries (2D Roll vs Sector)
246  me = 0;
247  me = dbe_->get(globalFolder_ + histoName.str()) ;
248  if ( 0!=me){
249  dbe_->removeElement(me->getName());
250  }
251 
252  CLSDisk[d+offset] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(),36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
253  rpcUtils.labelXAxisSegment(CLSDisk[d+offset]);
254  rpcUtils.labelYAxisRing(CLSDisk[d+offset], numberOfRings_,useRollInfo_ );
255 
256  if(testMode_){
257  histoName.str("");
258  histoName<<"ClusterSizeIn1Bin_Distribution_Disk"<<d; // ClusterSize in first bin, distribution
259  me = 0;
260  me = dbe_->get(globalFolder_ + histoName.str()) ;
261  if ( 0!=me){
262  dbe_->removeElement(me->getName());
263  }
264  CLSDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, 0.0, 1.0);
265 
266  histoName.str("");
267  histoName<<"ClusterSizeMean_Distribution_Disk"<<d; // Avarage ClusterSize Distribution
268  me = 0;
269  me = dbe_->get(globalFolder_ + histoName.str()) ;
270  if ( 0!=me){
271  dbe_->removeElement(me->getName());
272  }
273  MEANDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 10.5);
274 
275  }
276 
277  histoName.str("");
278  histoName<<"ClusterSizeMean_Ring_vs_Segment_Disk"<<d; // Avarage ClusterSize (2D Roll vs Sector)
279  me = 0;
280  me = dbe_->get(globalFolder_ + histoName.str()) ;
281  if ( 0!=me){
282  dbe_->removeElement(me->getName());
283  }
284 
285  MEANDisk[d+offset] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
286  rpcUtils.labelXAxisSegment(MEANDisk[d+offset]);
287  rpcUtils.labelYAxisRing(MEANDisk[d+offset], numberOfRings_ ,useRollInfo_);
288  }
289 }
void clientOperation(edm::EventSetup const &c)
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
MonitorElement * MEANWheel[kWheels]
tuple yBin
Definition: cuy.py:891
void beginRun(const edm::Run &r, const edm::EventSetup &c)
void labelXAxisSegment(MonitorElement *myMe)
Definition: utils.h:251
void labelYAxisRoll(MonitorElement *myMe, int region, int ring, bool useRollInfo)
Definition: utils.h:269
#define NULL
Definition: scimark2.h:8
MonitorElement * MEANDWheel[kWheels]
double getEntries(void) const
get # of entries
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * CLSDisk[kDisks]
MonitorElement * CLSDWheel[kWheels]
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:243
void labelYAxisRing(MonitorElement *myMe, int numberOfRings, bool useRollInfo)
Definition: utils.h:296
int roll() const
Definition: RPCDetId.h:120
void getMonitorElements(std::vector< MonitorElement * > &, std::vector< RPCDetId > &)
int ring() const
Definition: RPCDetId.h:72
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
MonitorElement * MEANDisk[kDisks]
MonitorElement * MEANDDisk[kDisks]
std::vector< MonitorElement * > myClusterMe_
unsigned int offset(bool)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1623
void endRun(const edm::Run &r, const edm::EventSetup &c)
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:236
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
Begin Lumi block.
virtual int segment()
Definition: RPCGeomServ.cc:467
int detId2RollNr(const RPCDetId &_id)
Definition: utils.h:18
void analyze(const edm::Event &iEvent, const edm::EventSetup &c)
Analyze.
std::vector< uint32_t > TagList
Definition: DQMNet.h:83
RPCClusterSizeTest(const edm::ParameterSet &ps)
Constructor.
std::vector< RPCDetId > myDetIds_
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
End Lumi Block.
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
double getBinContent(int binx) const
get content of bin (1-D)
MonitorElement * CLSDDisk[kDisks]
T w() const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
void beginJob(DQMStore *, std::string)
BeginJob.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
MonitorElement * CLSWheel[kWheels]
Definition: Run.h:41
virtual ~RPCClusterSizeTest()
Destructor.
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96