CMS 3D CMS Logo

RPCOccupancyTest.cc
Go to the documentation of this file.
1 /* \author Anna Cimmino*/
2 //#include <cmath>
3 #include <sstream>
6 
7 // Framework
9 //Geometry
11 
13  edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: Constructor";
14 
15  prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
16  numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 4);
17  numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
18  useNormalization_ = ps.getUntrackedParameter<bool>("testMode", true);
19  useRollInfo_ = ps.getUntrackedParameter<bool>("useRollInfo_", false);
20 
21  std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
22  std::string recHitTypeFolder= ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
23 
24  prefixDir_ = subsystemFolder+ "/"+ recHitTypeFolder;
25 
26 }
27 
29 
31  edm::LogVerbatim ("rpceventsummary") << "[RPCOccupancyTest]: Begin job ";
32  globalFolder_ = workingFolder;
33 
34  totalStrips_ = 0.;
35  totalActive_ = 0.;
36 }
37 
38 
39 void RPCOccupancyTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector, std::string & clientHistoName){
40  //Get NumberOfDigi ME for each roll
41  for(unsigned int i = 0 ; i<meVector.size(); i++){
42 
43  std::string meName = meVector[i]->getName();
44 
45  if(meName.find(clientHistoName) != std::string::npos){
46  myOccupancyMe_.push_back(meVector[i]);
47  myDetIds_.push_back(detIdVector[i]);
48  }
49  }
50 }
51 
53 
54  edm::LogVerbatim ("rpceventsummary") <<"[RPCOccupancyTest]: Client Operation";
55 
56  //Loop on MEs
57  for (unsigned int i = 0 ; i<myOccupancyMe_.size();i++){
59  }//End loop on MEs
60 
61  //Active Channels
62  if(Active_Fraction && totalStrips_!=0.){
64  }
65  if(Active_Dead){
68  }
69 
70 }
71 
72 
74 
76 
77  std::stringstream histoName;
78  rpcdqm::utils rpcUtils;
79 
80  histoName.str("");
81  histoName<<"RPC_Active_Channel_Fractions";
82  Active_Fraction = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 1, 0.5, 1.5);
83  Active_Fraction -> setBinLabel(1, "Active Fraction", 1);
84 
85  histoName.str("");
86  histoName<<"RPC_Active_Inactive_Strips";
87  Active_Dead = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 2, 0.5, 2.5);
88  Active_Dead -> setBinLabel(1, "Active Strips", 1);
89  Active_Dead -> setBinLabel(2, "Inactive Strips", 1);
90 
91  histoName.str("");
92  histoName<<"Barrel_OccupancyByStations_Normalized";
93  Barrel_OccBySt = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
94  Barrel_OccBySt -> setBinLabel(1, "St1", 1);
95  Barrel_OccBySt -> setBinLabel(2, "St2", 1);
96  Barrel_OccBySt -> setBinLabel(3, "St3", 1);
97  Barrel_OccBySt -> setBinLabel(4, "St4", 1);
98 
99 
100  histoName.str("");
101  histoName<<"EndCap_OccupancyByRings_Normalized";
102  EndCap_OccByRng = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 4, 0.5, 4.5);
103  EndCap_OccByRng -> setBinLabel(1, "E+/R3", 1);
104  EndCap_OccByRng -> setBinLabel(2, "E+/R2", 1);
105  EndCap_OccByRng -> setBinLabel(3, "E-/R2", 1);
106  EndCap_OccByRng -> setBinLabel(4, "E-/R3", 1);
107 
108  for (int w = -2; w<=2; w++ ){//loop on wheels
109 
110  histoName.str("");
111  histoName<<"AsymmetryLeftRight_Roll_vs_Sector_Wheel"<<w;
112 
113  AsyMeWheel[w+2] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
114 
115  rpcUtils.labelXAxisSector(AsyMeWheel[w+2]);
116  rpcUtils.labelYAxisRoll(AsyMeWheel[w+2], 0, w, useRollInfo_);
117 
118 
119  if(useNormalization_){
120 
121  histoName.str("");
122  histoName<<"OccupancyNormByEvents_Wheel"<<w;
123  NormOccupWheel[w+2] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
124 
125  rpcUtils.labelXAxisSector( NormOccupWheel[w+2]);
126  rpcUtils.labelYAxisRoll( NormOccupWheel[w+2], 0, w, useRollInfo_);
127 
128  histoName.str("");
129  histoName<<"OccupancyNormByEvents_Distribution_Wheel"<<w;
130 
131  NormOccupDWheel[w+2] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
132  }
133  }//end Barrel
134 
135  for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){
136 
137  if (d == 0)continue;
138 
139  int offset = numberOfDisks_;
140  if (d>0) offset --; //used to skip case equale to zero
141 
142  histoName.str("");
143  histoName<<"AsymmetryLeftRight_Ring_vs_Segment_Disk"<<d;
144  AsyMeDisk[d+offset] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
145 
146  rpcUtils.labelXAxisSegment(AsyMeDisk[d+offset]);
147  rpcUtils.labelYAxisRing(AsyMeDisk[d+offset], numberOfRings_, useRollInfo_);
148 
149 
150 
151  if(useNormalization_){
152 
153  histoName.str("");
154  histoName<<"OccupancyNormByEvents_Disk"<<d;
155  NormOccupDisk[d+offset] = ibooker.book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
156 
157  rpcUtils.labelXAxisSegment(NormOccupDisk[d+offset]);
159 
160  histoName.str("");
161  histoName<<"OccupancyNormByEvents_Distribution_Disk"<<d;
162  NormOccupDDisk[d+offset] = ibooker.book1D(histoName.str().c_str(), histoName.str().c_str(), 100, 0.0, 0.205);
163  }
164  }//End loop on Endcap
165 }
166 
167 
169 
170 
171 if (!myMe) return;
172 
173  MonitorElement * AsyMe=nullptr; //Left Right Asymetry
174  MonitorElement * NormOccup=nullptr;
175  MonitorElement * NormOccupD=nullptr;
176 
177  if(detId.region() ==0){
178  AsyMe= AsyMeWheel[detId.ring()+2];
179  if(useNormalization_){
180  NormOccup=NormOccupWheel[detId.ring()+2];
181  NormOccupD=NormOccupDWheel[detId.ring()+2];
182  }
183 
184  }else{
185 
186  if( -detId.station() + numberOfDisks_ >= 0 ){
187 
188  if(detId.region()<0){
189  AsyMe= AsyMeDisk[-detId.station() + numberOfDisks_];
190  if(useNormalization_){
191  NormOccup=NormOccupDisk[-detId.station() + numberOfDisks_];
192  NormOccupD=NormOccupDDisk[-detId.station() + numberOfDisks_];
193  }
194  }else{
195  AsyMe= AsyMeDisk[detId.station() + numberOfDisks_-1];
196  if(useNormalization_){
197  NormOccup=NormOccupDisk[detId.station() + numberOfDisks_-1];
198  NormOccupD=NormOccupDDisk[detId.station() + numberOfDisks_-1];
199  }
200  }
201  }
202  }
203 
204 
205  int xBin,yBin;
206  if(detId.region()==0){//Barrel
207  xBin= detId.sector();
208  rpcdqm::utils rollNumber;
209  yBin = rollNumber.detId2RollNr(detId);
210  }else{//Endcap
211  //get segment number
212  RPCGeomServ RPCServ(detId);
213  xBin = RPCServ.segment();
214  (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
215  }
216 
217 
218  int stripInRoll=myMe->getNbinsX();
219  totalStrips_ += (float)stripInRoll;
220  float FOccupancy=0;
221  float BOccupancy=0;
222 
223  float totEnt = myMe->getEntries();
224  for(int strip = 1 ; strip<=stripInRoll; strip++){
225  float stripEntries = myMe->getBinContent(strip);
226  if(stripEntries > 0) {totalActive_++;}
227  if(strip<=stripInRoll/2) {FOccupancy+=myMe->getBinContent(strip);}
228  else {BOccupancy+=myMe->getBinContent(strip);}
229  }
230 
231 
232  float asym = 0;
233  if(totEnt != 0 ) asym = fabs((FOccupancy - BOccupancy )/totEnt);
234 
235  if(AsyMe) AsyMe->setBinContent(xBin,yBin,asym);
236 
237 
238 
239  float normoccup = 1;
240  if(rpcevents_ != 0){ normoccup = (totEnt/rpcevents_);}
241 
242  if(useNormalization_){
243  if(NormOccup) NormOccup->setBinContent(xBin,yBin, normoccup);
244  if(NormOccupD) NormOccupD->Fill(normoccup);
245  }
246 
247 
248  if(detId.region()==0) {
249  if(Barrel_OccBySt)Barrel_OccBySt -> Fill(detId.station(), normoccup);
250  }else if(detId.region()==1) {
251  if(detId.ring()==3) {
252  EndCap_OccByRng -> Fill(1, normoccup);
253  } else {
254  EndCap_OccByRng -> Fill(2, normoccup);
255  }
256  } else {
257  if(detId.ring()==3) {
258  EndCap_OccByRng -> Fill(4, normoccup);
259  }else {
260  EndCap_OccByRng -> Fill(3, normoccup);
261  }
262  }
263 
264 }
265 
266 
267 
268 
269 
T getUntrackedParameter(std::string const &, T const &) const
void clientOperation() override
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * AsyMeWheel[5]
const double w
Definition: UKUtility.cc:23
MonitorElement * NormOccupDDisk[10]
void labelXAxisSegment(MonitorElement *myMe)
Definition: utils.h:264
MonitorElement * EndCap_OccByRng
void labelYAxisRoll(MonitorElement *myMe, int region, int ring, bool useRollInfo)
Definition: utils.h:283
MonitorElement * Active_Fraction
std::vector< RPCDetId > myDetIds_
void Fill(long long x)
MonitorElement * NormOccupDWheel[5]
MonitorElement * Barrel_OccBySt
void labelYAxisRing(MonitorElement *myMe, int numberOfRings, bool useRollInfo)
Definition: utils.h:311
int roll() const
Definition: RPCDetId.h:120
~RPCOccupancyTest() override
MonitorElement * NormOccupWheel[5]
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int ring() const
Definition: RPCDetId.h:72
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
MonitorElement * AsyMeDisk[10]
std::string globalFolder_
void labelXAxisSector(MonitorElement *myMe)
Definition: utils.h:249
void fillGlobalME(RPCDetId &, MonitorElement *)
void myBooker(DQMStore::IBooker &) override
virtual int segment()
Definition: RPCGeomServ.cc:469
int detId2RollNr(const RPCDetId &_id)
Definition: utils.h:31
double getEntries() const
get # of entries
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
MonitorElement * Active_Dead
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
std::string prefixDir_
RPCOccupancyTest(const edm::ParameterSet &ps)
double getBinContent(int binx) const
get content of bin (1-D)
void getMonitorElements(std::vector< MonitorElement * > &, std::vector< RPCDetId > &, std::string &) override
void beginJob(std::string &) override
std::vector< MonitorElement * > myOccupancyMe_
int getNbinsX() const
get # of bins in X-axis
yBin
Definition: cuy.py:891
MonitorElement * NormOccupDisk[10]
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96