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 
22 
23 void RPCClusterSizeTest::beginJob(DQMStore * dbe, std::string workingFolder){
24  edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: Begin job ";
25 
26  globalFolder_ = workingFolder;
27  dbe_ = dbe;
28 }
29 
31  edm::LogVerbatim ("rpceventsummary") << "[RPCClusterSizeTest]: End run";
32 }
33 
34 void RPCClusterSizeTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector){
35 
36 
37  //Get ME for each roll
38  for (unsigned int i = 0 ; i<meVector.size(); i++){
39 
40  bool flag= false;
41 
43  tagList = meVector[i]->getTags();
44  DQMNet::TagList::iterator tagItr = tagList.begin();
45 
46  while (tagItr != tagList.end() && !flag ) {
47  if((*tagItr) == rpcdqm::CLUSTERSIZE)
48  flag= true;
49 
50  tagItr++;
51  }
52 
53  if(flag){
54  myClusterMe_.push_back(meVector[i]);
55  myDetIds_.push_back(detIdVector[i]);
56  }
57  }
58 
59 }
60 
62 
64 
66 
68 
69  edm::LogVerbatim ("rpceventsummary") <<"[RPCClusterSizeTest]:Client Operation";
70 
71  //check some statements and prescale Factor
72  if(myClusterMe_.size()==0 || myDetIds_.size()==0)return;
73 
74  MonitorElement * CLS =NULL; // ClusterSize in 1 bin, Roll vs Sector
75  MonitorElement * CLSD =NULL; // ClusterSize in 1 bin, Distribution
76  MonitorElement * MEAN =NULL; // Mean ClusterSize, Roll vs Sector
77  MonitorElement * MEAND =NULL; // Mean ClusterSize, Distribution
78 
79 
80  std::stringstream meName;
81  RPCDetId detId;
82  MonitorElement * myMe;
83 
84 
85  //Loop on chambers
86  for (unsigned int i = 0 ; i<myClusterMe_.size();i++){
87 
88  myMe = myClusterMe_[i];
89  if (!myMe || myMe->getEntries()==0 )continue;
90 
91 
92  detId=myDetIds_[i];
93 
94 
95  if (detId.region()==0){
96 
97  CLS=CLSWheel[detId.ring()+2];
98  MEAN= MEANWheel[detId.ring()+2];
99  if(testMode_){
100  CLSD=CLSDWheel[detId.ring()+2];
101  MEAND=MEANDWheel[detId.ring()+2];
102  }
103  }else {
104 
105  if(((detId.station() * detId.region() ) + numberOfDisks_) >= 0 ){
106 
107  if(detId.region()<0){
108  CLS=CLSDisk[(detId.station() * detId.region() ) + numberOfDisks_];
109  MEAN= MEANDisk[(detId.station() * detId.region() ) + numberOfDisks_];
110  if(testMode_){
111  CLSD = CLSDDisk[(detId.station() * detId.region() ) + numberOfDisks_];
112  MEAND= MEANDDisk[(detId.station() * detId.region() ) + numberOfDisks_];
113  }
114  }else{
115  CLS=CLSDisk[(detId.station() * detId.region() ) + numberOfDisks_ -1];
116  MEAN= MEANDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
117  if(testMode_){
118  CLSD = CLSDDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
119  MEAND= MEANDDisk[(detId.station() * detId.region() ) + numberOfDisks_-1];
120  }
121  }
122  }
123 
124  }
125 
126 
127  int xBin,yBin;
128 
129  if (detId.region()==0){//Barrel
130 
131  rpcdqm::utils rollNumber;
132  yBin = rollNumber.detId2RollNr(detId);
133  xBin = detId.sector();
134  }else {//Endcap
135 
136  //get segment number
137  RPCGeomServ RPCServ(detId);
138  xBin = RPCServ.segment();
139  (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
140  }
141 
142  // Normalization -> # of Entries in first Bin normalaized by total Entries
143 
144  float NormCLS = myMe->getBinContent(1)/myMe->getEntries();
145  float meanCLS = myMe->getMean();
146 
147  if (CLS) CLS -> setBinContent(xBin,yBin, NormCLS);
148  if(MEAN) MEAN -> setBinContent(xBin, yBin, meanCLS);
149 
150  if(testMode_){
151  if(MEAND) MEAND->Fill(meanCLS);
152  if(CLSD) CLSD->Fill(NormCLS);
153  }
154 
155  }//End loop on chambers
156 }
157 
160  MonitorElement* me;
162 
163  std::stringstream histoName;
164 
165  rpcdqm::utils rpcUtils;
166 
167 
168  for (int w = -2; w<=2;w++ ){//loop on wheels
169 
170  histoName.str("");
171  histoName<<"ClusterSizeIn1Bin_Roll_vs_Sector_Wheel"<<w; // ClusterSize in first bin norm. by Entries (2D Roll vs Sector)
172  me = 0;
173  me = dbe_->get(globalFolder_ + histoName.str()) ;
174  if ( 0!=me ) {
175  dbe_->removeElement(me->getName());
176  }
177 
178  CLSWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
179  rpcUtils.labelXAxisSector( CLSWheel[w+2]);
180  rpcUtils.labelYAxisRoll( CLSWheel[w+2], 0, w ,useRollInfo_);
181 
182 
183  histoName.str("");
184  histoName<<"ClusterSizeMean_Roll_vs_Sector_Wheel"<<w; // Avarage ClusterSize (2D Roll vs Sector)
185  me = 0;
186  me = dbe_->get(globalFolder_ + histoName.str()) ;
187  if ( 0!=me) {
188  dbe_->removeElement(me->getName());
189  }
190 
191  MEANWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
192 
193  rpcUtils.labelXAxisSector( MEANWheel[w+2]);
194  rpcUtils.labelYAxisRoll(MEANWheel[w+2], 0, w,useRollInfo_ );
195 
196  if(testMode_){
197  histoName.str("");
198  histoName<<"ClusterSizeIn1Bin_Distribution_Wheel"<<w; // ClusterSize in first bin, distribution
199  me = 0;
200  me = dbe_->get(globalFolder_ + histoName.str()) ;
201  if ( 0!=me ) {
202  dbe_->removeElement(me->getName());
203  }
204  CLSDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, 0.0, 1.0);
205 
206 
207  histoName.str("");
208  histoName<<"ClusterSizeMean_Distribution_Wheel"<<w; // Avarage ClusterSize Distribution
209  me = 0;
210  me = dbe_->get(globalFolder_ + histoName.str()) ;
211  if ( 0!=me){
212  dbe_->removeElement(me->getName());
213  }
214  MEANDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 10.5);
215  }
216  }//end loop on wheels
217 
218 
219  for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){
220  if (d == 0 )continue;
221  //Endcap
222  int offset = numberOfDisks_;
223  if (d>0) offset --;
224 
225  histoName.str("");
226  histoName<<"ClusterSizeIn1Bin_Ring_vs_Segment_Disk"<<d; // ClusterSize in first bin norm. by Entries (2D Roll vs Sector)
227  me = 0;
228  me = dbe_->get(globalFolder_ + histoName.str()) ;
229  if ( 0!=me){
230  dbe_->removeElement(me->getName());
231  }
232 
233  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);
234  rpcUtils.labelXAxisSegment(CLSDisk[d+offset]);
235  rpcUtils.labelYAxisRing(CLSDisk[d+offset], numberOfRings_,useRollInfo_ );
236 
237  if(testMode_){
238  histoName.str("");
239  histoName<<"ClusterSizeIn1Bin_Distribution_Disk"<<d; // ClusterSize in first bin, distribution
240  me = 0;
241  me = dbe_->get(globalFolder_ + histoName.str()) ;
242  if ( 0!=me){
243  dbe_->removeElement(me->getName());
244  }
245  CLSDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 20, 0.0, 1.0);
246 
247  histoName.str("");
248  histoName<<"ClusterSizeMean_Distribution_Disk"<<d; // Avarage ClusterSize Distribution
249  me = 0;
250  me = dbe_->get(globalFolder_ + histoName.str()) ;
251  if ( 0!=me){
252  dbe_->removeElement(me->getName());
253  }
254  MEANDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.5, 10.5);
255 
256  }
257 
258  histoName.str("");
259  histoName<<"ClusterSizeMean_Ring_vs_Segment_Disk"<<d; // Avarage ClusterSize (2D Roll vs Sector)
260  me = 0;
261  me = dbe_->get(globalFolder_ + histoName.str()) ;
262  if ( 0!=me){
263  dbe_->removeElement(me->getName());
264  }
265 
266  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);
267  rpcUtils.labelXAxisSegment(MEANDisk[d+offset]);
268  rpcUtils.labelYAxisRing(MEANDisk[d+offset], numberOfRings_ ,useRollInfo_);
269 
270  }
271 
272 
273 
274 }
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 * CLSDDisk[10]
long int flag
Definition: mlp_lapack.h:47
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
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
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)
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:124
void getMonitorElements(std::vector< MonitorElement * > &, std::vector< RPCDetId > &)
int ring() const
Definition: RPCDetId.h:76
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
MonitorElement * MEANDWheel[5]
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:1468
void endRun(const edm::Run &r, const edm::EventSetup &c)
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:236
MonitorElement * MEANWheel[5]
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
Begin Lumi block.
MonitorElement * CLSDWheel[5]
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:106
double getBinContent(int binx) const
get content of bin (1-D)
MonitorElement * MEANDDisk[10]
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:845
MonitorElement * CLSDisk[10]
void beginJob(DQMStore *, std::string)
BeginJob.
MonitorElement * CLSWheel[5]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
virtual ~RPCClusterSizeTest()
Destructor.
MonitorElement * MEANDisk[10]
T w() const
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:67
int station() const
Definition: RPCDetId.h:100