CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Attributes
RPCEfficiency Class Reference

#include <RPCEfficiency.h>

Inheritance diagram for RPCEfficiency:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
void bookDetUnitSeg (RPCDetId &detId, int nstrips, std::string folder, std::map< std::string, MonitorElement * > &)
 
virtual void endJob ()
 
virtual void endRun (const edm::Run &r, const edm::EventSetup &iSetup)
 
 RPCEfficiency (const edm::ParameterSet &)
 
 ~RPCEfficiency ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Public Attributes

MonitorElementhGlobalResClu1La [6]
 
MonitorElementhGlobalResClu1R2A
 
MonitorElementhGlobalResClu1R2B
 
MonitorElementhGlobalResClu1R2C
 
MonitorElementhGlobalResClu1R3A
 
MonitorElementhGlobalResClu1R3B
 
MonitorElementhGlobalResClu1R3C
 
MonitorElementhGlobalResClu2La [6]
 
MonitorElementhGlobalResClu2R2A
 
MonitorElementhGlobalResClu2R2B
 
MonitorElementhGlobalResClu2R2C
 
MonitorElementhGlobalResClu2R3A
 
MonitorElementhGlobalResClu2R3B
 
MonitorElementhGlobalResClu2R3C
 
MonitorElementhGlobalResClu3La [6]
 
MonitorElementhGlobalResClu3R2A
 
MonitorElementhGlobalResClu3R2B
 
MonitorElementhGlobalResClu3R2C
 
MonitorElementhGlobalResClu3R3A
 
MonitorElementhGlobalResClu3R3B
 
MonitorElementhGlobalResClu3R3C
 
std::map< CSCStationIndex,
std::set< RPCDetId > > 
rollstoreCSC
 
std::map< DTStationIndex,
std::set< RPCDetId > > 
rollstoreDT
 
MonitorElementstatistics
 

Private Attributes

std::vector< std::map
< RPCDetId, int > > 
counter
 
edm::InputTag cscSegments
 
DQMStoredbe
 
bool debug
 
edm::InputTag dt4DSegments
 
int dupli
 
std::string EffRootFileName
 
bool EffSaveRootFile
 
std::string folderPath
 
bool inclcsc
 
bool incldt
 
bool incldtMB4
 
bool inves
 
double MaxD
 
double MaxDrb4
 
std::map< int, std::map
< std::string, MonitorElement * > > 
meCollection
 
double MinCosAng
 
double rangestrips
 
double rangestripsRB4
 
std::string rollseff
 
edm::InputTag RPCRecHitLabel_
 
std::vector< int > totalcounter
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Class for RPC Monitoring using RPCDigi and DT and CSC Segments.

Date:
2012/02/09 10:26:51
Revision:
1.9
Author
Camilo Carrillo (Uniandes)

Definition at line 107 of file RPCEfficiency.h.

Constructor & Destructor Documentation

RPCEfficiency::RPCEfficiency ( const edm::ParameterSet iConfig)
explicit

Definition at line 37 of file RPCEfficiency.cc.

References gather_cfg::cout, cscSegments, dbe, debug, dt4DSegments, dupli, EffRootFileName, EffSaveRootFile, folderPath, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hGlobalResClu1La, hGlobalResClu1R2A, hGlobalResClu1R2B, hGlobalResClu1R2C, hGlobalResClu1R3A, hGlobalResClu1R3B, hGlobalResClu1R3C, hGlobalResClu2La, hGlobalResClu2R2A, hGlobalResClu2R2B, hGlobalResClu2R2C, hGlobalResClu2R3A, hGlobalResClu2R3B, hGlobalResClu2R3C, hGlobalResClu3La, hGlobalResClu3R2A, hGlobalResClu3R2B, hGlobalResClu3R2C, hGlobalResClu3R3A, hGlobalResClu3R3B, hGlobalResClu3R3C, inclcsc, incldt, incldtMB4, MaxD, MaxDrb4, MinCosAng, cppFunctionSkipper::operator, rangestrips, rangestripsRB4, RPCRecHitLabel_, MonitorElement::setBinLabel(), and statistics.

37  {
38  incldt=iConfig.getUntrackedParameter<bool>("incldt",true);
39  incldtMB4=iConfig.getUntrackedParameter<bool>("incldtMB4",true);
40  inclcsc=iConfig.getUntrackedParameter<bool>("inclcsc",true);
41  debug=iConfig.getUntrackedParameter<bool>("debug",false);
42 
43  rangestrips = iConfig.getUntrackedParameter<double>("rangestrips",4.);
44  rangestripsRB4=iConfig.getUntrackedParameter<double>("rangestripsRB4",4.);
45  dupli = iConfig.getUntrackedParameter<int>("DuplicationCorrection",2);
46  MinCosAng=iConfig.getUntrackedParameter<double>("MinCosAng",0.96);
47  MaxD=iConfig.getUntrackedParameter<double>("MaxD",80.);
48  MaxDrb4=iConfig.getUntrackedParameter<double>("MaxDrb4",150.);
49 
50 
51  // muonRPCDigis=iConfig.getUntrackedParameter<std::string>("muonRPCDigis","muonRPCDigis");
52  cscSegments=iConfig.getParameter<edm::InputTag>("cscSegments");
53  dt4DSegments=iConfig.getParameter<edm::InputTag>("dt4DSegments");
54  RPCRecHitLabel_ = iConfig.getParameter<edm::InputTag>("RecHitLabel");
55 
56 
57  folderPath=iConfig.getUntrackedParameter<std::string>("folderPath","RPC/RPCEfficiency/");
58 
59  EffSaveRootFile = iConfig.getUntrackedParameter<bool>("EffSaveRootFile", false);
60  EffRootFileName = iConfig.getUntrackedParameter<std::string>("EffRootFileName", "RPCEfficiency.root");
61 
62  //Interface
63 
65 
66  std::string folder;
67  dbe->setCurrentFolder(folderPath);
68  statistics = dbe->book1D("Statistics","All Statistics",33,0.5,33.5);
69 
70  statistics->setBinLabel(1,"Events ",1);
71  statistics->setBinLabel(2,"Events with DT seg",1);
72  statistics->setBinLabel(3,"1 DT seg",1);
73  statistics->setBinLabel(4,"2 DT seg",1);
74  statistics->setBinLabel(5,"3 DT seg",1);
75  statistics->setBinLabel(6,"4 DT seg",1);
76  statistics->setBinLabel(7,"5 DT seg",1);
77  statistics->setBinLabel(8,"6 DT seg",1);
78  statistics->setBinLabel(9,"7 DT seg",1);
79  statistics->setBinLabel(10,"8 DT seg",1);
80  statistics->setBinLabel(11,"9 DT seg",1);
81  statistics->setBinLabel(12,"10 DT seg",1);
82  statistics->setBinLabel(13,"11 DT seg",1);
83  statistics->setBinLabel(14,"12 DT seg",1);
84  statistics->setBinLabel(15,"13 DT seg",1);
85  statistics->setBinLabel(16,"14 DT seg",1);
86  statistics->setBinLabel(17,"15 DT seg",1);
87  statistics->setBinLabel(18,"Events with CSC seg",1);
88  statistics->setBinLabel(16+3,"1 CSC seg",1);
89  statistics->setBinLabel(16+4,"2 CSC seg",1);
90  statistics->setBinLabel(16+5,"3 CSC seg",1);
91  statistics->setBinLabel(16+6,"4 CSC seg",1);
92  statistics->setBinLabel(16+7,"5 CSC seg",1);
93  statistics->setBinLabel(16+8,"6 CSC seg",1);
94  statistics->setBinLabel(16+9,"7 CSC seg",1);
95  statistics->setBinLabel(16+10,"8 CSC seg",1);
96  statistics->setBinLabel(16+11,"9 CSC seg",1);
97  statistics->setBinLabel(16+12,"10 CSC seg",1);
98  statistics->setBinLabel(16+13,"11 CSC seg",1);
99  statistics->setBinLabel(16+14,"12 CSC seg",1);
100  statistics->setBinLabel(16+15,"13 CSC seg",1);
101  statistics->setBinLabel(16+16,"14 CSC seg",1);
102  statistics->setBinLabel(16+17,"15 CSC seg",1);
103 
104  if(debug) std::cout<<"booking Global histograms with "<<folderPath<<std::endl;
105 
106  folder = folderPath+"MuonSegEff/"+"Residuals/Barrel";
107  dbe->setCurrentFolder(folder);
108 
109  //Barrel
110  std::stringstream histoName, histoTitle;
111 
112  for (int layer = 1 ; layer<= 6 ;layer++){
113  histoName.str("");
114  histoTitle.str("");
115  histoName<<"GlobalResidualsClu1La"<<layer;
116  histoTitle<<"RPC Residuals Layer "<<layer<<" Cluster Size 1";
117  hGlobalResClu1La[layer-1] = dbe->book1D(histoName.str(), histoTitle.str(),101,-10.,10.);
118 
119  histoName.str("");
120  histoTitle.str("");
121  histoName<<"GlobalResidualsClu2La"<<layer;
122  histoTitle<<"RPC Residuals Layer "<<layer<<" Cluster Size 2";
123  hGlobalResClu2La[layer-1] = dbe->book1D(histoName.str(), histoTitle.str(),101,-10.,10.);
124 
125  histoName.str("");
126  histoTitle.str("");
127  histoName<<"GlobalResidualsClu3La"<<layer;
128  histoTitle<<"RPC Residuals Layer "<<layer<<" Cluster Size 3";
129  hGlobalResClu3La[layer-1] = dbe->book1D(histoName.str(), histoTitle.str(),101,-10.,10.);
130 
131  }
132 
133  if(debug) std::cout<<"Booking Residuals for EndCap"<<std::endl;
134  folder = folderPath+"MuonSegEff/Residuals/EndCap";
135  dbe->setCurrentFolder(folder);
136 
137  //Endcap
138 
139  hGlobalResClu1R3C = dbe->book1D("GlobalResidualsClu1R3C","RPC Residuals Ring 3 Roll C Cluster Size 1",101,-10.,10.);
140  hGlobalResClu1R3B = dbe->book1D("GlobalResidualsClu1R3B","RPC Residuals Ring 3 Roll B Cluster Size 1",101,-10.,10.);
141  hGlobalResClu1R3A = dbe->book1D("GlobalResidualsClu1R3A","RPC Residuals Ring 3 Roll A Cluster Size 1",101,-10.,10.);
142  hGlobalResClu1R2C = dbe->book1D("GlobalResidualsClu1R2C","RPC Residuals Ring 2 Roll C Cluster Size 1",101,-10.,10.);
143  hGlobalResClu1R2B = dbe->book1D("GlobalResidualsClu1R2B","RPC Residuals Ring 2 Roll B Cluster Size 1",101,-10.,10.);
144  hGlobalResClu1R2A = dbe->book1D("GlobalResidualsClu1R2A","RPC Residuals Ring 2 Roll A Cluster Size 1",101,-10.,10.);
145 
146  hGlobalResClu2R3C = dbe->book1D("GlobalResidualsClu2R3C","RPC Residuals Ring 3 Roll C Cluster Size 2",101,-10.,10.);
147  hGlobalResClu2R3B = dbe->book1D("GlobalResidualsClu2R3B","RPC Residuals Ring 3 Roll B Cluster Size 2",101,-10.,10.);
148  hGlobalResClu2R3A = dbe->book1D("GlobalResidualsClu2R3A","RPC Residuals Ring 3 Roll A Cluster Size 2",101,-10.,10.);
149  hGlobalResClu2R2C = dbe->book1D("GlobalResidualsClu2R2C","RPC Residuals Ring 2 Roll C Cluster Size 2",101,-10.,10.);
150  hGlobalResClu2R2B = dbe->book1D("GlobalResidualsClu2R2B","RPC Residuals Ring 2 Roll B Cluster Size 2",101,-10.,10.);
151  hGlobalResClu2R2A = dbe->book1D("GlobalResidualsClu2R2A","RPC Residuals Ring 2 Roll A Cluster Size 2",101,-10.,10.);
152 
153  hGlobalResClu3R3C = dbe->book1D("GlobalResidualsClu3R3C","RPC Residuals Ring 3 Roll C Cluster Size 3",101,-10.,10.);
154  hGlobalResClu3R3B = dbe->book1D("GlobalResidualsClu3R3B","RPC Residuals Ring 3 Roll B Cluster Size 3",101,-10.,10.);
155  hGlobalResClu3R3A = dbe->book1D("GlobalResidualsClu3R3A","RPC Residuals Ring 3 Roll A Cluster Size 3",101,-10.,10.);
156  hGlobalResClu3R2C = dbe->book1D("GlobalResidualsClu3R2C","RPC Residuals Ring 2 Roll C Cluster Size 3",101,-10.,10.);
157  hGlobalResClu3R2B = dbe->book1D("GlobalResidualsClu3R2B","RPC Residuals Ring 2 Roll B Cluster Size 3",101,-10.,10.);
158  hGlobalResClu3R2A = dbe->book1D("GlobalResidualsClu3R2A","RPC Residuals Ring 2 Roll A Cluster Size 3",101,-10.,10.);
159 
160 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * hGlobalResClu1R2A
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
MonitorElement * hGlobalResClu1R3A
MonitorElement * hGlobalResClu3R2C
MonitorElement * hGlobalResClu2La[6]
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * hGlobalResClu3R3C
edm::InputTag dt4DSegments
DQMStore * dbe
std::string EffRootFileName
MonitorElement * hGlobalResClu3La[6]
std::string folderPath
MonitorElement * hGlobalResClu3R2A
double rangestripsRB4
MonitorElement * hGlobalResClu1R3B
MonitorElement * hGlobalResClu1R2C
MonitorElement * hGlobalResClu2R3C
MonitorElement * hGlobalResClu3R3A
MonitorElement * statistics
MonitorElement * hGlobalResClu2R2A
edm::InputTag cscSegments
MonitorElement * hGlobalResClu2R3A
edm::InputTag RPCRecHitLabel_
MonitorElement * hGlobalResClu1La[6]
double rangestrips
tuple cout
Definition: gather_cfg.py:121
MonitorElement * hGlobalResClu1R3C
MonitorElement * hGlobalResClu2R2B
MonitorElement * hGlobalResClu3R3B
MonitorElement * hGlobalResClu3R2B
MonitorElement * hGlobalResClu2R3B
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
MonitorElement * hGlobalResClu1R2B
MonitorElement * hGlobalResClu2R2C
RPCEfficiency::~RPCEfficiency ( )

Definition at line 262 of file RPCEfficiency.cc.

262 {}

Member Function Documentation

void RPCEfficiency::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 264 of file RPCEfficiency.cc.

References CSCDetId::chamber(), gather_cfg::cout, cscSegments, debug, distsector_tmp(), dt4DSegments, dupli, CSCDetId::endcap(), MonitorElement::Fill(), edm::EventSetup::get(), edm::Event::getByLabel(), hGlobalResClu1La, hGlobalResClu1R2A, hGlobalResClu1R2B, hGlobalResClu1R2C, hGlobalResClu1R3A, hGlobalResClu1R3B, hGlobalResClu1R3C, hGlobalResClu2La, hGlobalResClu2R2A, hGlobalResClu2R2B, hGlobalResClu2R2C, hGlobalResClu2R3A, hGlobalResClu2R3B, hGlobalResClu2R3C, hGlobalResClu3La, hGlobalResClu3R2A, hGlobalResClu3R2B, hGlobalResClu3R2C, hGlobalResClu3R3A, hGlobalResClu3R3B, hGlobalResClu3R3C, RPCRoll::id(), CSCChamber::id(), inclcsc, incldt, incldtMB4, edm::HandleBase::isValid(), RPCDetId::layer(), RectangularStripTopology::localPosition(), TrapezoidalStripTopology::localPosition(), MaxD, MaxDrb4, meCollection, MinCosAng, RPCGeomServ::name(), RPCRoll::nstrips(), RectangularStripTopology::pitch(), TrapezoidalStripTopology::pitch(), rangestrips, DetId::rawId(), RPCDetId::ring(), CSCDetId::ring(), RPCDetId::roll(), rollstoreCSC, rollstoreDT, RPCRecHitLabel_, DTChamberId::sector(), mathSSE::sqrt(), DTChamberId::station(), CSCDetId::station(), RPCDetId::station(), statistics, RPCRoll::strip(), RectangularStripTopology::stripLength(), TrapezoidalStripTopology::stripLength(), GeomDet::surface(), GeomDet::toGlobal(), Surface::toGlobal(), GeomDet::toLocal(), GloballyPositioned< T >::toLocal(), RPCRoll::topology(), DTChamberId::wheel(), X, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), Gflash::Z, and PV3DBase< T, PVType, FrameType >::z().

264  {
265 
266 
270 
271  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
272  iSetup.get<MuonGeometryRecord>().get(dtGeo);
273  iSetup.get<MuonGeometryRecord>().get(cscGeo);
274 
275  statistics->Fill(1);
276 
277  std::stringstream meIdRPC, meIdDT, meIdCSC;
278 
279  if(debug) std::cout <<"\t Getting the RPC RecHits"<<std::endl;
281  iEvent.getByLabel(RPCRecHitLabel_,rpcHits);
282 
283  if(!rpcHits.isValid()) return;
284 
285  if(incldt){
286  if(debug) std::cout<<"\t Getting the DT Segments"<<std::endl;
288 
289  iEvent.getByLabel(dt4DSegments, all4DSegments);
290 
291  if(all4DSegments.isValid()){
292 
293  if(all4DSegments->size()>0){
294 
295  if(all4DSegments->size()<=16) statistics->Fill(2);
296 
297  if(debug) std::cout<<"\t Number of DT Segments in this event = "<<all4DSegments->size()<<std::endl;
298 
299  std::map<DTChamberId,int> DTSegmentCounter;
301 
302  for (segment = all4DSegments->begin();segment!=all4DSegments->end(); ++segment){
303  DTSegmentCounter[segment->chamberId()]++;
304  }
305 
306  statistics->Fill(all4DSegments->size()+2);
307 
308  if(debug) std::cout<<"\t Loop over all the 4D Segments"<<std::endl;
309  for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
310 
311  DTChamberId DTId = segment->chamberId();
312 
313 
314  if(DTSegmentCounter[DTId]==1 && DTId.station()!=4){
315 
316  int dtWheel = DTId.wheel();
317  int dtStation = DTId.station();
318  int dtSector = DTId.sector();
319 
320  LocalPoint segmentPosition= segment->localPosition();
321  LocalVector segmentDirection=segment->localDirection();
322 
323  const GeomDet* gdet=dtGeo->idToDet(segment->geographicalId());
324  const BoundPlane & DTSurface = gdet->surface();
325 
326  //check if the dimension of the segment is 4
327 
328  if(segment->dimension()==4){
329 
330  float Xo=segmentPosition.x();
331  float Yo=segmentPosition.y();
332  float Zo=segmentPosition.z();
333  float dx=segmentDirection.x();
334  float dy=segmentDirection.y();
335  float dz=segmentDirection.z();
336 
337  std::set<RPCDetId> rollsForThisDT = rollstoreDT[DTStationIndex(0,dtWheel,dtSector,dtStation)];
338 
339  if(debug) std::cout<<"DT \t \t Loop over all the rolls asociated to this DT"<<std::endl;
340  for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++){
341  const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
342  RPCDetId rpcId = rollasociated->id();
343  const BoundPlane & RPCSurface = rollasociated->surface();
344 
345 // RPCGeomServ rpcsrv(rpcId);
346 // std::string nameRoll = rpcsrv.name();
347 
348  GlobalPoint CenterPointRollGlobal = RPCSurface.toGlobal(LocalPoint(0,0,0));
349 
350  LocalPoint CenterRollinDTFrame = DTSurface.toLocal(CenterPointRollGlobal);
351 
352  float D=CenterRollinDTFrame.z();
353 
354  float X=Xo+dx*D/dz;
355  float Y=Yo+dy*D/dz;
356  float Z=D;
357 
358  const RectangularStripTopology* top_= dynamic_cast<const RectangularStripTopology*> (&(rollasociated->topology()));
359  LocalPoint xmin = top_->localPosition(0.);
360  if(debug) std::cout<<"DT \t \t \t xmin of this Roll "<<xmin<<"cm"<<std::endl;
361  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
362  if(debug) std::cout<<"DT \t \t \t xmax of this Roll "<<xmax<<"cm"<<std::endl;
363  float rsize = fabs( xmax.x()-xmin.x() );
364  if(debug) std::cout<<"DT \t \t \t Roll Size "<<rsize<<"cm"<<std::endl;
365  float stripl = top_->stripLength();
366  float stripw = top_->pitch();
367 
368  float extrapolatedDistance = sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
369 
370  if(extrapolatedDistance<=MaxD){
371 
372  GlobalPoint GlobalPointExtrapolated = DTSurface.toGlobal(LocalPoint(X,Y,Z));
373  LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
374 
375  if(fabs(PointExtrapolatedRPCFrame.z()) < 10. &&
376  fabs(PointExtrapolatedRPCFrame.x()) < rsize*0.5 &&
377  fabs(PointExtrapolatedRPCFrame.y()) < stripl*0.5){
378 
379  RPCDetId rollId = rollasociated->id();
380  RPCGeomServ rpcsrv(rollId);
381  std::string nameRoll = rpcsrv.name();
382  if(debug) std::cout<<"DT \t \t \t \t The RPCName is "<<nameRoll<<std::endl;
383  const float stripPredicted =
384  rollasociated->strip(LocalPoint(PointExtrapolatedRPCFrame.x(),PointExtrapolatedRPCFrame.y(),0.));
385 
386  if(debug) std::cout<<"DT \t \t \t \t Candidate (from DT Segment) STRIP---> "<<stripPredicted<< std::endl;
387  //---- HISTOGRAM STRIP PREDICTED FROM DT ----
388 
389  std::map<std::string, MonitorElement*> meMap=meCollection[rpcId.rawId()];
390  meIdDT.str("");
391  meIdDT<<"ExpectedOccupancyFromDT_"<<rollId.rawId();
392  meMap[meIdDT.str()]->Fill(stripPredicted);
393  //-----------------------------------------------------
394 
395 
396  //-------RecHitPart Just For Residual--------
397  int countRecHits = 0;
398  int cluSize = 0;
399  float minres = 3000.;
400 
401  typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
402  rangeRecHits recHitCollection = rpcHits->get(rollasociated->id());
404 
405  for (recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++) {
406  countRecHits++;
407 
408  // sprintf(meIdRPC,"BXDistribution_%d",rollasociated->id().rawId());
409 // meMap[meIdRPC]->Fill(recHit->BunchX());
410 
411  LocalPoint recHitPos=recHit->localPosition();
412  float res=PointExtrapolatedRPCFrame.x()- recHitPos.x();
413  if(debug) std::cout<<"DT \t \t \t \t \t Found Rec Hit at "<<res<<"cm of the prediction."<<std::endl;
414  if(fabs(res)<fabs(minres)){
415  minres=res;
416  cluSize = recHit->clusterSize();
417  if(debug) std::cout<<"DT \t \t \t \t \t \t New Min Res "<<res<<"cm."<<std::endl;
418  }
419  }
420 
421  if(countRecHits==0){
422  if(debug) std::cout <<"DT \t \t \t \t \t THIS ROLL DOESN'T HAVE ANY RECHIT"<<std::endl;
423  }else{
424  assert(minres!=3000);
425 
426  if(fabs(minres)<=(rangestrips+cluSize*0.5)*stripw){
427  if(debug) std::cout<<"DT \t \t \t \t \t \t True!"<<std::endl;
428 
429  // float cosal = dx/sqrt(dx*dx+dz*dz);
430 
431  if(rollId.station()==1&&rollId.layer()==1) {
432  if(cluSize==1*dupli) {hGlobalResClu1La[0]->Fill(minres);}
433  else if(cluSize==2*dupli){ hGlobalResClu2La[0]->Fill(minres);}
434  else if(cluSize==3*dupli){ hGlobalResClu3La[0]->Fill(minres);}}
435  else if(rollId.station()==1&&rollId.layer()==2){
436  if(cluSize==1*dupli) {hGlobalResClu1La[1]->Fill(minres);}
437  else if(cluSize==2*dupli){ hGlobalResClu2La[1]->Fill(minres);}
438  else if(cluSize==3*dupli){ hGlobalResClu3La[1]->Fill(minres);}}
439  else if(rollId.station()==2&&rollId.layer()==1){
440  if(cluSize==1*dupli) {hGlobalResClu1La[2]->Fill(minres);}
441  else if(cluSize==2*dupli){ hGlobalResClu2La[2]->Fill(minres);}
442  else if(cluSize==3*dupli){ hGlobalResClu3La[2]->Fill(minres);}
443  }
444  else if(rollId.station()==2&&rollId.layer()==2){
445  if(cluSize==1*dupli) {hGlobalResClu1La[3]->Fill(minres);}
446  if(cluSize==2*dupli){ hGlobalResClu2La[3]->Fill(minres);}
447  else if(cluSize==3*dupli){ hGlobalResClu3La[3]->Fill(minres);}
448  }
449  else if(rollId.station()==3){
450  if(cluSize==1*dupli) {hGlobalResClu1La[4]->Fill(minres);}
451  else if(cluSize==2*dupli){ hGlobalResClu2La[4]->Fill(minres);}
452  else if(cluSize==3*dupli){ hGlobalResClu3La[4]->Fill(minres);}
453  }
454  meIdRPC.str("");
455  meIdRPC<<"RPCDataOccupancyFromDT_"<<rollId.rawId();
456  meMap[meIdRPC.str()]->Fill(stripPredicted);
457  }
458  }
459  }else{
460  if(debug) std::cout<<"DT \t \t \t \t No the prediction is outside of this roll"<<std::endl;
461  }//Condition for the right match
462  }else{
463  if(debug) std::cout<<"DT \t \t \t No, Exrtrapolation too long!, canceled"<<std::endl;
464  }//D so big
465  }//loop over all the rolls asociated
466  }//Is the segment 4D?
467  }else {
468  if(debug) std::cout<<"DT \t \t More than one segment in this chamber, or we are in Station 4"<<std::endl;
469  }
470  }
471  } else {
472  if(debug) std::cout<<"DT This Event doesn't have any DT4DDSegment"<<std::endl; //is ther more than 1 segment in this event?
473  }
474  }
475  }
476 
477  if(incldtMB4){
479  iEvent.getByLabel(dt4DSegments, all4DSegments);
480 
481  if(all4DSegments.isValid() && all4DSegments->size()>0){
482 
483  std::map<DTChamberId,int> DTSegmentCounter;
485 
486  for (segment = all4DSegments->begin();segment!=all4DSegments->end(); ++segment){
487  DTSegmentCounter[segment->chamberId()]++;
488  }
489 
490  if(debug) std::cout<<"MB4 \t \t Loop Over all4DSegments"<<std::endl;
491  for (segment = all4DSegments->begin(); segment != all4DSegments->end(); ++segment){
492 
493  DTChamberId DTId = segment->chamberId();
494 
495  if(DTSegmentCounter[DTId] == 1 && DTId.station()==4){
496  int dtWheel = DTId.wheel();
497  int dtStation = DTId.station();
498  int dtSector = DTId.sector();
499 
500  LocalPoint segmentPosition= segment->localPosition();
501  LocalVector segmentDirection=segment->localDirection();
502 
503  //check if the dimension of the segment is 2 and the station is 4
504 
505  if(segment->dimension()==2){
506  LocalVector segmentDirectionMB4=segmentDirection;
507  LocalPoint segmentPositionMB4=segmentPosition;
508 
509 
510  const BoundPlane& DTSurface4 = dtGeo->idToDet(DTId)->surface();
511 
513 
514  for(segMB3=all4DSegments->begin();segMB3!=all4DSegments->end();++segMB3){
515 
516  DTChamberId dtid3 = segMB3->chamberId();
517 
518  if(distsector_tmp(dtid3.sector(),DTId.sector())<=1
519  && dtid3.station()==3
520  && dtid3.wheel()==DTId.wheel()
521  && DTSegmentCounter[dtid3] == 1
522  && segMB3->dimension()==4){
523 
524  const GeomDet* gdet3=dtGeo->idToDet(segMB3->geographicalId());
525  const BoundPlane & DTSurface3 = gdet3->surface();
526 
527  LocalVector segmentDirectionMB3 = segMB3->localDirection();
528  GlobalPoint segmentPositionMB3inGlobal = DTSurface3.toGlobal(segMB3->localPosition());
529 
530  GlobalVector segDirMB4inGlobalFrame=DTSurface4.toGlobal(segmentDirectionMB4);
531  GlobalVector segDirMB3inGlobalFrame=DTSurface3.toGlobal(segmentDirectionMB3);
532 
533  float dx=segDirMB4inGlobalFrame.x();
534  float dy=segDirMB4inGlobalFrame.y();
535  // float dz=segDirMB4inGlobalFrame.z();
536 
537  float dx3=segDirMB3inGlobalFrame.x();
538  float dy3=segDirMB3inGlobalFrame.y();
539  // float dz3=segDirMB3inGlobalFrame.z();
540 
541  double cosAng=fabs(dx*dx3+dy*dy3/sqrt((dx3*dx3+dy3*dy3)*(dx*dx+dy*dy)));
542 
543  if(cosAng>MinCosAng){
544  if(dtSector==13){
545  dtSector=4;
546  }
547  if(dtSector==14){
548  dtSector=10;
549  }
550 
551  std::set<RPCDetId> rollsForThisDT = rollstoreDT[DTStationIndex(0,dtWheel,dtSector,dtStation)]; //It should be always 4
552 
553  assert(rollsForThisDT.size()>=1);
554 
555  for (std::set<RPCDetId>::iterator iteraRoll=rollsForThisDT.begin();iteraRoll != rollsForThisDT.end(); iteraRoll++){
556  const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll); //roll asociado a MB4
557  const BoundPlane & RPCSurfaceRB4 = rollasociated->surface(); //surface MB4
558 
559  // RPCGeomServ rpcsrv(rpcId);
560  // std::string nameRoll = rpcsrv.name();
561 
562  GlobalPoint CenterPointRollGlobal=RPCSurfaceRB4.toGlobal(LocalPoint(0,0,0));
563  LocalPoint CenterRollinMB4Frame = DTSurface4.toLocal(CenterPointRollGlobal); //In MB4
564  LocalPoint segmentPositionMB3inMB4Frame = DTSurface4.toLocal(segmentPositionMB3inGlobal); //In MB4
565  LocalVector segmentDirectionMB3inMB4Frame = DTSurface4.toLocal(segDirMB3inGlobalFrame); //In MB4
566 
567  //The exptrapolation is done in MB4 frame. for local x and z is done from MB4,
568  float Dxz=CenterRollinMB4Frame.z();
569  float Xo4=segmentPositionMB4.x();
570  float dxl=segmentDirectionMB4.x(); //dx local for MB4 segment in MB4 Frame
571  float dzl=segmentDirectionMB4.z(); //dx local for MB4 segment in MB4 Frame
572 
573  float X=Xo4+dxl*Dxz/dzl; //In MB4 frame
574  float Z=Dxz;//In MB4 frame
575 
576  //for local y is done from MB3
577  float Yo34=segmentPositionMB3inMB4Frame.y();
578  float dy34 = segmentDirectionMB3inMB4Frame.y();
579  float dz34 = segmentDirectionMB3inMB4Frame.z();
580  float Dy=Dxz-(segmentPositionMB3inMB4Frame.z()); //Distance beetween the segment in MB3 and the RB4 surface
581 
582  float Y=Yo34+dy34*Dy/dz34;//In MB4 Frame
583 
584  const RectangularStripTopology* top_
585  =dynamic_cast<const RectangularStripTopology*>(&(rollasociated->topology())); //Topology roll asociated MB4
586  LocalPoint xmin = top_->localPosition(0.);
587  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
588  float rsize = fabs( xmax.x()-xmin.x() );
589  float stripl = top_->stripLength();
590  float stripw = top_->pitch();
591 
592  float extrapolatedDistance = sqrt((Y-Yo34)*(Y-Yo34)+Dy*Dy);
593 
594  if(extrapolatedDistance<=MaxDrb4){
595 
596  GlobalPoint GlobalPointExtrapolated = DTSurface4.toGlobal(LocalPoint(X,Y,Z));
597  LocalPoint PointExtrapolatedRPCFrame = RPCSurfaceRB4.toLocal(GlobalPointExtrapolated);
598 
599  if(fabs(PointExtrapolatedRPCFrame.z()) < 5. &&
600  fabs(PointExtrapolatedRPCFrame.x()) < rsize*0.5 &&
601  fabs(PointExtrapolatedRPCFrame.y()) < stripl*0.5){
602 
603  RPCDetId rollId = rollasociated->id();
604 
605  // RPCGeomServ rpcsrv(rollId);
606 // std::string nameRoll = rpcsrv.name();
607 // if(debug) std::cout<<"MB4 \t \t \t \t \t The RPCName is "<<nameRoll<<std::endl;
608  const float stripPredicted=
609  rollasociated->strip(LocalPoint(PointExtrapolatedRPCFrame.x(),PointExtrapolatedRPCFrame.y(),0.));
610 
611  if(debug) std::cout<<"MB4 \t \t \t \t Candidate (from DT Segment) STRIP---> "<<stripPredicted<< std::endl;
612  //--------- HISTOGRAM STRIP PREDICTED FROM DT MB4 -------------------
613 
614  std::map<std::string, MonitorElement*> meMap=meCollection[rollId.rawId()];
615 
616  meIdDT.str("");
617  meIdDT<<"ExpectedOccupancyFromDT_"<<rollId.rawId();
618  meMap[meIdDT.str()]->Fill(stripPredicted);
619  //-------------------------------------------------
620 
621 
622  //-------RecHitPart Just For Residual--------
623  int countRecHits = 0;
624  int cluSize = 0;
625  float minres = 3000.;
626 
627  if(debug) std::cout<<"MB4 \t \t \t \t Getting RecHits in Roll Asociated"<<std::endl;
628  typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
629  rangeRecHits recHitCollection = rpcHits->get(rollasociated->id());
631 
632  for (recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++) {
633  countRecHits++;
634  LocalPoint recHitPos=recHit->localPosition();
635  float res=PointExtrapolatedRPCFrame.x()- recHitPos.x();
636  if(debug) std::cout<<"DT \t \t \t \t \t Found Rec Hit at "<<res<<"cm of the prediction."<<std::endl;
637  if(fabs(res)<fabs(minres)){
638  minres=res;
639  cluSize = recHit->clusterSize();
640  }
641  }
642 
643  if(countRecHits==0){
644  if(debug) std::cout <<"MB4 \t \t \t \t \t \t THIS ROLL DOESN'T HAVE ANY RECHIT"<<std::endl;
645  }else{
646  assert(minres!=3000);
647 
648  if(fabs(minres)<=(rangestrips+cluSize*0.5)*stripw){
649  assert(rollId.station()==4);
650  if(cluSize==1*dupli){ hGlobalResClu1La[5]->Fill(minres);}
651  else if(cluSize==2*dupli){ hGlobalResClu2La[5]->Fill(minres);}
652  else if(cluSize==3*dupli){ hGlobalResClu3La[5]->Fill(minres);}
653 
654  meIdRPC.str("");
655  meIdRPC<<"RPCDataOccupancyFromDT_"<<rollId.rawId();
656  meMap[meIdRPC.str()]->Fill(stripPredicted);
657  }
658  }
659  }else{
660  if(debug) std::cout<<"MB4 \t \t \t \t No the prediction is outside of this roll"<<std::endl;
661  }
662  }//Condition for the right match
663  else{
664  if(debug) std::cout<<"MB4 \t \t \t No, Exrtrapolation too long!, canceled"<<std::endl;
665  }
666  }//loop over all the rollsasociated
667  }else{
668  if(debug) std::cout<<"MB4 \t \t \t \t I found segments in MB4 and MB3 adjacent or same wheel and sector but not compatibles Diferent Directions"<<std::endl;
669  }
670  }else{//if dtid3.station()==3&&dtid3.sector()==DTId.sector()&&dtid3.wheel()==DTId.wheel()&&segMB3->dim()==4
671  if(debug) std::cout<<"MB4 \t \t \t No the same station or same wheel or segment dim in mb3 not 4D"<<std::endl;
672  }
673  }//loop over all the segments looking for one in MB3
674  }else{
675  if(debug) std::cout<<"MB4 \t \t \t Is NOT a 2D Segment"<<std::endl;
676  }
677  }else{
678  if(debug) std::cout<<"MB4 \t \t \t \t There is not just one segment or is not in station 4"<<std::endl;
679  }//De aca para abajo esta en dtpart.inl
680  }
681  }else{
682  if(debug) std::cout<<"MB4 \t This event doesn't have 4D Segment"<<std::endl;
683  }
684 
685  }
686 
687 
688  if(inclcsc){
689  if(debug) std::cout <<"\t Getting the CSC Segments"<<std::endl;
690  edm::Handle<CSCSegmentCollection> allCSCSegments;
691 
692  iEvent.getByLabel(cscSegments, allCSCSegments);
693 
694  if(allCSCSegments.isValid()){
695  if(allCSCSegments->size()>0){
696  statistics->Fill(18);
697 
698  if(debug) std::cout<<"CSC \t Number of CSC Segments in this event = "<<allCSCSegments->size()<<std::endl;
699 
700  std::map<CSCDetId,int> CSCSegmentsCounter;
702 
703  int segmentsInThisEventInTheEndcap=0;
704 
705  for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
706  CSCSegmentsCounter[segment->cscDetId()]++;
707  segmentsInThisEventInTheEndcap++;
708  }
709 
710  statistics->Fill(allCSCSegments->size()+18);
711 
712  if(debug) std::cout<<"CSC \t loop over all the CSCSegments "<<std::endl;
713  for (segment = allCSCSegments->begin();segment!=allCSCSegments->end(); ++segment){
714  CSCDetId CSCId = segment->cscDetId();
715 
716  if(CSCSegmentsCounter[CSCId]==1 && CSCId.station()!=4 && CSCId.ring()!=1 && allCSCSegments->size()>=2){
717  if(debug) std::cout<<"CSC \t \t yes"<<std::endl;
718  int cscEndCap = CSCId.endcap();
719  int cscStation = CSCId.station();
720  int cscRing = CSCId.ring();
721  // int cscChamber = CSCId.chamber();
722  int rpcRegion = 1; if(cscEndCap==2) rpcRegion= -1;//Relacion entre las endcaps
723  int rpcRing = cscRing;
724  if(cscRing==4)rpcRing =1;
725  int rpcStation = cscStation;
726  int rpcSegment = CSCId.chamber();
727 
728  LocalPoint segmentPosition= segment->localPosition();
729  LocalVector segmentDirection=segment->localDirection();
730  float dz=segmentDirection.z();
731 
732  if(debug) std::cout<<"CSC \t \t Is a good Segment? dim = 4, 4 <= nRecHits <= 10 Incident angle int range 45 < "<<acos(dz)*180/3.1415926<<" < 135? "<<std::endl;
733 
734  if(segment->dimension()==4 && (segment->nRecHits()<=10 && segment->nRecHits()>=4)&& acos(dz)*180/3.1415926 > 45. && acos(dz)*180/3.1415926 < 160. ){
735 
736  float Xo=segmentPosition.x();
737  float Yo=segmentPosition.y();
738  float Zo=segmentPosition.z();
739  float dx=segmentDirection.x();
740  float dy=segmentDirection.y();
741  float dz=segmentDirection.z();
742 
743 
744  if(debug) std::cout<<"CSC \t \t Getting chamber from Geometry"<<std::endl;
745  const CSCChamber* TheChamber=cscGeo->chamber(CSCId);
746  if(debug) std::cout<<"CSC \t \t Getting ID from Chamber"<<std::endl;
747  const CSCDetId TheId=TheChamber->id();
748  if(debug) std::cout<<"CSC \t \t Printing The Id"<<TheId<<std::endl;
749  std::set<RPCDetId> rollsForThisCSC = rollstoreCSC[CSCStationIndex(rpcRegion,rpcStation,rpcRing,rpcSegment)];
750  if(debug) std::cout<<"CSC \t \t Number of rolls for this CSC = "<<rollsForThisCSC.size()<<std::endl;
751 
752  if(rpcRing!=1&&rpcStation!=4){
753 
754  //Loop over all the rolls
755  for (std::set<RPCDetId>::iterator iteraRoll = rollsForThisCSC.begin();iteraRoll != rollsForThisCSC.end(); iteraRoll++){
756 
757  const RPCRoll* rollasociated = rpcGeo->roll(*iteraRoll);
758  RPCDetId rpcId = rollasociated->id();
759 
760  const BoundPlane & RPCSurface = rollasociated->surface();
761 
762  GlobalPoint CenterPointRollGlobal = RPCSurface.toGlobal(LocalPoint(0,0,0));
763  LocalPoint CenterRollinCSCFrame = TheChamber->toLocal(CenterPointRollGlobal);
764 
765  float D=CenterRollinCSCFrame.z();
766 
767  float X=Xo+dx*D/dz;
768  float Y=Yo+dy*D/dz;
769  float Z=D;
770 
771  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(rollasociated->topology()));
772  LocalPoint xmin = top_->localPosition(0.);
773  if(debug) std::cout<<"CSC \t \t \t xmin of this Roll "<<xmin<<"cm"<<std::endl;
774  LocalPoint xmax = top_->localPosition((float)rollasociated->nstrips());
775  if(debug) std::cout<<"CSC \t \t \t xmax of this Roll "<<xmax<<"cm"<<std::endl;
776  float rsize = fabs( xmax.x()-xmin.x() );
777  if(debug) std::cout<<"CSC \t \t \t Roll Size "<<rsize<<"cm"<<std::endl;
778  float stripl = top_->stripLength();
779  float stripw = top_->pitch();
780 
781 
782  float extrapolatedDistance = sqrt((X-Xo)*(X-Xo)+(Y-Yo)*(Y-Yo)+(Z-Zo)*(Z-Zo));
783 
784 
785  if(extrapolatedDistance<=MaxD){
786 
787  GlobalPoint GlobalPointExtrapolated=TheChamber->toGlobal(LocalPoint(X,Y,Z));
788  LocalPoint PointExtrapolatedRPCFrame = RPCSurface.toLocal(GlobalPointExtrapolated);
789 
790 
791  if(fabs(PointExtrapolatedRPCFrame.z()) < 10. &&
792  fabs(PointExtrapolatedRPCFrame.x()) < rsize*0.5 &&
793  fabs(PointExtrapolatedRPCFrame.y()) < stripl*0.5){
794 
795  RPCDetId rollId = rollasociated->id();
796  RPCGeomServ rpcsrv(rollId);
797  std::string nameRoll = rpcsrv.name();
798 
799  if(debug) std::cout<<"CSC \t \t \t \t The RPCName is "<<nameRoll<<std::endl;
800 
801  const float stripPredicted =
802  rollasociated->strip(LocalPoint(PointExtrapolatedRPCFrame.x(),PointExtrapolatedRPCFrame.y(),0.));
803 
804  if(debug) std::cout<<"CSC \t \t \t \t \t Candidate"<<rollId<<" "<<"(from CSC Segment) STRIP---> "<<stripPredicted<< std::endl;
805  //--------- HISTOGRAM STRIP PREDICTED FROM CSC -------------------
806 
807  std::map<std::string, MonitorElement*> meMap=meCollection[rpcId.rawId()];
808  meIdCSC.str("");
809  meIdCSC<<"ExpectedOccupancyFromCSC_"<<rollId.rawId();
810  meMap[meIdCSC.str()]->Fill(stripPredicted);
811  //--------------------------------------------------------------------
812 
813 
814  //-------RecHitPart Just For Residual--------
815  int cluSize = 0;
816  int countRecHits = 0;
817  float minres = 3000.;
818 
819  if(debug) std::cout<<"CSC \t \t \t \t \t Getting RecHits in Roll Asociated"<<std::endl;
820  typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
821  rangeRecHits recHitCollection = rpcHits->get(rollasociated->id());
823 
824  for (recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++) {
825 
826  countRecHits++;
827  LocalPoint recHitPos=recHit->localPosition();
828  float res=PointExtrapolatedRPCFrame.x()- recHitPos.x();
829  if(debug) std::cout<<"CSC \t \t \t \t \t \t Found Rec Hit at "<<res<<"cm of the prediction."<<std::endl;
830  if(fabs(res)<fabs(minres)){
831  minres=res;
832  cluSize = recHit->clusterSize();
833  if(debug) std::cout<<"CSC \t \t \t \t \t \t \t New Min Res "<<res<<"cm."<<std::endl;
834  }
835  }
836 
837  if(countRecHits==0){
838  if(debug) std::cout <<"CSC \t \t \t \t \t THIS ROLL DOESN'T HAVE ANY RECHIT"<<std::endl;
839  }else{
840  assert(minres!=3000);
841 
842  if(fabs(minres)<=(rangestrips+cluSize*0.5)*stripw){
843  if(debug) std::cout<<"CSC \t \t \t \t \t \t True!"<<std::endl;
844 
845  if(rollId.ring()==2&&rollId.roll()==1){
846  if(cluSize==1*dupli) hGlobalResClu1R2A->Fill(minres);
847  else if(cluSize==2*dupli) hGlobalResClu2R2A->Fill(minres);
848  else if(cluSize==3*dupli) hGlobalResClu3R2A->Fill(minres);
849  }
850  else if(rollId.ring()==2&&rollId.roll()==2){
851  if(cluSize==1*dupli) hGlobalResClu1R2B->Fill(minres);
852  else if(cluSize==2*dupli) hGlobalResClu2R2B->Fill(minres);
853  else if(cluSize==3*dupli) hGlobalResClu3R2B->Fill(minres);
854  }
855  else if(rollId.ring()==2&&rollId.roll()==3){
856  if(cluSize==1*dupli) hGlobalResClu1R2C->Fill(minres);
857  else if(cluSize==2*dupli) hGlobalResClu2R2C->Fill(minres);
858  else if(cluSize==3*dupli) hGlobalResClu3R2C->Fill(minres);
859  }
860  else if(rollId.ring()==3&&rollId.roll()==1){
861  if(cluSize==1*dupli) hGlobalResClu1R3A->Fill(minres);
862  else if(cluSize==2*dupli) hGlobalResClu2R3A->Fill(minres);
863  else if(cluSize==3*dupli) hGlobalResClu3R3A->Fill(minres);
864  }
865  else if(rollId.ring()==3&&rollId.roll()==2){
866  if(cluSize==1*dupli) hGlobalResClu1R3B->Fill(minres);
867  else if(cluSize==2*dupli) hGlobalResClu2R3B->Fill(minres);
868  else if(cluSize==3*dupli) hGlobalResClu3R3B->Fill(minres);
869  }
870  else if(rollId.ring()==3&&rollId.roll()==3){if(cluSize==1*dupli) hGlobalResClu1R3C->Fill(minres); if(cluSize==2*dupli) hGlobalResClu2R3C->Fill(minres); if(cluSize==3*dupli) hGlobalResClu3R3C->Fill(minres);
871  }
872  meIdRPC.str("");
873  meIdRPC<<"RPCDataOccupancyFromCSC_"<<rollId.rawId();
874  meMap[meIdRPC.str()]->Fill(stripPredicted);
875  }
876  }
877 
878  }else{
879  if(debug) std::cout<<"CSC \t \t \t \t No the prediction is outside of this roll"<<std::endl;
880  }//Condition for the right match
881  }else{//if extrapolation distance D is not too long
882  if(debug) std::cout<<"CSC \t \t \t No, Exrtrapolation too long!, canceled"<<std::endl;
883  }//D so big
884  }//loop over the rolls asociated
885  }//Condition over the startup geometry!!!!
886  }//Is the segment 4D?
887  }else{
888  if(debug) std::cout<<"CSC \t \t More than one segment in this chamber, or we are in Station Ring 1 or in Station 4"<<std::endl;
889  }
890  }
891  }else{
892  if(debug) std::cout<<"CSC This Event doesn't have any CSCSegment"<<std::endl;
893  }
894  }
895  }
896 
897 }
const double Z[kNumberCalorimeter]
int chamber() const
Definition: CSCDetId.h:70
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
float strip(const LocalPoint &lp) const
Definition: RPCRoll.cc:71
const Topology & topology() const
Definition: RPCRoll.cc:30
int distsector_tmp(int sector1, int sector2)
MonitorElement * hGlobalResClu1R2A
virtual float stripLength() const
CSCDetId id() const
Get the (concrete) DetId.
Definition: CSCChamber.h:37
MonitorElement * hGlobalResClu1R3A
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
int nstrips() const
Definition: RPCRoll.cc:46
MonitorElement * hGlobalResClu3R2C
MonitorElement * hGlobalResClu2La[6]
T y() const
Definition: PV3DBase.h:62
#define X(str)
Definition: MuonsGrabber.cc:49
MonitorElement * hGlobalResClu3R3C
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
std::map< int, std::map< std::string, MonitorElement * > > meCollection
edm::InputTag dt4DSegments
void Fill(long long x)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int endcap() const
Definition: CSCDetId.h:95
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
RPCDetId id() const
Definition: RPCRoll.cc:24
int roll() const
Definition: RPCDetId.h:124
MonitorElement * hGlobalResClu3La[6]
int ring() const
Definition: RPCDetId.h:76
T sqrt(T t)
Definition: SSEVec.h:46
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:63
MonitorElement * hGlobalResClu3R2A
MonitorElement * hGlobalResClu1R3B
MonitorElement * hGlobalResClu1R2C
MonitorElement * hGlobalResClu2R3C
MonitorElement * hGlobalResClu3R3A
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::map< CSCStationIndex, std::set< RPCDetId > > rollstoreCSC
MonitorElement * statistics
std::map< DTStationIndex, std::set< RPCDetId > > rollstoreDT
int ring() const
Definition: CSCDetId.h:77
int layer() const
Definition: RPCDetId.h:112
MonitorElement * hGlobalResClu2R2A
edm::InputTag cscSegments
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
MonitorElement * hGlobalResClu2R3A
const T & get() const
Definition: EventSetup.h:55
edm::InputTag RPCRecHitLabel_
MonitorElement * hGlobalResClu1La[6]
virtual LocalPoint localPosition(float strip) const
double rangestrips
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
int sector() const
Definition: DTChamberId.h:63
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
int station() const
Definition: CSCDetId.h:88
tuple cout
Definition: gather_cfg.py:121
MonitorElement * hGlobalResClu1R3C
MonitorElement * hGlobalResClu2R2B
virtual LocalPoint localPosition(float strip) const
int station() const
Return the station number.
Definition: DTChamberId.h:53
MonitorElement * hGlobalResClu3R3B
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
T x() const
Definition: PV3DBase.h:61
virtual float stripLength() const
det heigth (strip length in the middle)
MonitorElement * hGlobalResClu3R2B
MonitorElement * hGlobalResClu2R3B
MonitorElement * hGlobalResClu1R2B
MonitorElement * hGlobalResClu2R2C
int station() const
Definition: RPCDetId.h:100
void RPCEfficiency::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 21 of file RPCEfficiency.cc.

21 {}
void RPCEfficiency::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 162 of file RPCEfficiency.cc.

References bookDetUnitSeg(), gather_cfg::cout, debug, folderPath, edm::EventSetup::get(), inclcsc, incldt, incldtMB4, meCollection, alignCSCRings::r, DetId::rawId(), RPCDetId::region(), relativeConstraints::ring, RPCDetId::ring(), RPCChamber::rolls(), rollstoreCSC, rollstoreDT, RPCDetId::sector(), RPCGeomServ::segment(), relativeConstraints::station, and RPCDetId::station().

162  {
163 
165  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
166 
167 
168  for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();it<rpcGeo->dets().end();it++){
169  if(dynamic_cast< RPCChamber* >( *it ) != 0 ){
170  RPCChamber* ch = dynamic_cast< RPCChamber* >( *it );
171  std::vector< const RPCRoll*> roles = (ch->rolls());
172  for(std::vector<const RPCRoll*>::const_iterator r = roles.begin();r != roles.end(); ++r){
173 
174  RPCDetId rpcId = (*r)->id();
175  int region=rpcId.region();
176  //booking all histograms
177 
178  // std::string nameRoll = rpcsrv.name();
179 
180  if(debug) std::cout<<"Booking for "<<rpcId.rawId()<<std::endl;
181 
182  bookDetUnitSeg(rpcId,(*r)->nstrips(),folderPath+"MuonSegEff/", meCollection[rpcId.rawId()] );
183 
184  if(region==0&&(incldt||incldtMB4)){
185  //std::cout<<"--Filling the dtstore"<<rpcId<<std::endl;
186  int wheel=rpcId.ring();
187  int sector=rpcId.sector();
188  int station=rpcId.station();
189  DTStationIndex ind(region,wheel,sector,station);
190  std::set<RPCDetId> myrolls;
191  if (rollstoreDT.find(ind)!=rollstoreDT.end()) myrolls=rollstoreDT[ind];
192  myrolls.insert(rpcId);
193  rollstoreDT[ind]=myrolls;
194 
195  }else if(region!=0 && inclcsc){
196  int station=rpcId.station();
197  int ring=rpcId.ring();
198  int cscring=ring;
199  int cscstation=station;
200  RPCGeomServ rpcsrv(rpcId);
201  int rpcsegment = rpcsrv.segment();
202  int cscchamber = rpcsegment;
203  if((station==2||station==3)&&ring==3){
204  cscring = 2;
205  }
206 
207  CSCStationIndex ind(region,cscstation,cscring,cscchamber);
208  std::set<RPCDetId> myrolls;
209  if (rollstoreCSC.find(ind)!=rollstoreCSC.end()){
210  myrolls=rollstoreCSC[ind];
211  }
212  myrolls.insert(rpcId);
213  rollstoreCSC[ind]=myrolls;
214  }
215  }
216  }
217  }
218  for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();it<rpcGeo->dets().end();it++){
219  if( dynamic_cast< RPCChamber* >( *it ) != 0 ){
220 
221  RPCChamber* ch = dynamic_cast< RPCChamber* >( *it );
222  std::vector< const RPCRoll*> roles = (ch->rolls());
223  for(std::vector<const RPCRoll*>::const_iterator r = roles.begin();r != roles.end(); ++r){
224  RPCDetId rpcId = (*r)->id();
225 
226  int region=rpcId.region();
227 
228  if(region!=0 && inclcsc && (rpcId.ring()==2 || rpcId.ring()==3)){
229  int region=rpcId.region();
230  int station=rpcId.station();
231  int ring=rpcId.ring();
232  int cscring = ring;
233 
234  if((station==2||station==3)&&ring==3) cscring = 2; //CSC Ring 2 covers rpc ring 2 & 3
235 
236 
237  int cscstation=station;
238  RPCGeomServ rpcsrv(rpcId);
239  int rpcsegment = rpcsrv.segment();
240 
241  int cscchamber = rpcsegment+1;
242  if(cscchamber==37)cscchamber=1;
243  CSCStationIndex ind(region,cscstation,cscring,cscchamber);
244  std::set<RPCDetId> myrolls;
245  if (rollstoreCSC.find(ind)!=rollstoreCSC.end())myrolls=rollstoreCSC[ind];
246  myrolls.insert(rpcId);
247  rollstoreCSC[ind]=myrolls;
248 
249  cscchamber = rpcsegment-1;
250  if(cscchamber==0)cscchamber=36;
251  CSCStationIndex indDos(region,cscstation,cscring,cscchamber);
252  std::set<RPCDetId> myrollsDos;
253  if (rollstoreCSC.find(indDos)!=rollstoreCSC.end()) myrollsDos=rollstoreCSC[indDos];
254  myrollsDos.insert(rpcId);
255  rollstoreCSC[indDos]=myrollsDos;
256  }
257  }
258  }
259  }
260 }//beginRun
std::map< int, std::map< std::string, MonitorElement * > > meCollection
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
void bookDetUnitSeg(RPCDetId &detId, int nstrips, std::string folder, std::map< std::string, MonitorElement * > &)
int ring() const
Definition: RPCDetId.h:76
std::string folderPath
const std::vector< const RPCRoll * > & rolls() const
Return the Rolls.
Definition: RPCChamber.cc:70
std::map< CSCStationIndex, std::set< RPCDetId > > rollstoreCSC
std::map< DTStationIndex, std::set< RPCDetId > > rollstoreDT
const T & get() const
Definition: EventSetup.h:55
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:106
tuple cout
Definition: gather_cfg.py:121
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:67
int station() const
Definition: RPCDetId.h:100
void RPCEfficiency::bookDetUnitSeg ( RPCDetId detId,
int  nstrips,
std::string  folder,
std::map< std::string, MonitorElement * > &  meMap 
)

Definition at line 13 of file RPCEfficiencyBook.cc.

References DQMStore::book1D(), dbe, DetId::rawId(), RPCDetId::region(), and DQMStore::setCurrentFolder().

Referenced by beginRun().

13  {
14 
15  //std::map<std::string, MonitorElement*> meMap;
16 
17  dbe->setCurrentFolder(folder);
18 
19  char meId [128];
20  char meTitle [128];
21 
22  int rawId = detId.rawId();
23 
24  //Begin booking DT
25  if(detId.region()==0) {
26 
27  sprintf(meId,"ExpectedOccupancyFromDT_%d",rawId);
28  sprintf(meTitle,"ExpectedOccupancyFromDT_for_%d",rawId);
29  meMap[meId] = dbe->book1D(meId, meTitle, nstrips, 0.5, nstrips+0.5);
30 
31  sprintf(meId,"RPCDataOccupancyFromDT_%d",rawId);
32  sprintf(meTitle,"RPCDataOccupancyFromDT_for_%d",rawId);
33  meMap[meId] = dbe->book1D(meId, meTitle, nstrips, 0.5, nstrips+0.5);
34 
35  // sprintf(meId,"BXDistribution_%d",rawId);
36 // sprintf(meTitle,"BXDistribution_for_%d",rawId);
37 // meMap[meId] = dbe->book1D(meId, meTitle, 11,-5.5, 5.5);
38  }else{
39  //std::cout<<"Booking for the EndCap"<<detUnitLabel<<std::endl;
40 
41  sprintf(meId,"ExpectedOccupancyFromCSC_%d",rawId);
42  sprintf(meTitle,"ExpectedOccupancyFromCSC_for_%d",rawId);
43  meMap[meId] = dbe->book1D(meId, meTitle, nstrips, 0.5, nstrips+0.5);
44 
45  sprintf(meId,"RPCDataOccupancyFromCSC_%d",rawId);
46  sprintf(meTitle,"RPCDataOccupancyFromCSC_for_%d",rawId);
47  meMap[meId] = dbe->book1D(meId, meTitle, nstrips, 0.5, nstrips+0.5);
48 
49  // sprintf(meId,"BXDistribution_%d",rawId);
50 // sprintf(meTitle,"BXDistribution_for_%d",rawId);
51 // meMap[meId] = dbe->book1D(meId, meTitle, 11,-5.5, 5.5);
52  }
53  //return meMap;
54 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
DQMStore * dbe
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:67
void RPCEfficiency::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 907 of file RPCEfficiency.cc.

References dbe.

907  {
908  dbe =0;
909 }
DQMStore * dbe
void RPCEfficiency::endRun ( const edm::Run r,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 900 of file RPCEfficiency.cc.

References dbe, EffRootFileName, EffSaveRootFile, and DQMStore::save().

900  {
901  if (EffSaveRootFile){
903  }
904 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
DQMStore * dbe
std::string EffRootFileName

Member Data Documentation

std::vector<std::map<RPCDetId, int> > RPCEfficiency::counter
private

Definition at line 158 of file RPCEfficiency.h.

edm::InputTag RPCEfficiency::cscSegments
private

Definition at line 175 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

DQMStore* RPCEfficiency::dbe
private

Definition at line 187 of file RPCEfficiency.h.

Referenced by bookDetUnitSeg(), endJob(), endRun(), and RPCEfficiency().

bool RPCEfficiency::debug
private

Definition at line 164 of file RPCEfficiency.h.

Referenced by analyze(), beginRun(), and RPCEfficiency().

edm::InputTag RPCEfficiency::dt4DSegments
private

Definition at line 176 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

int RPCEfficiency::dupli
private

Definition at line 172 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

std::string RPCEfficiency::EffRootFileName
private

Definition at line 186 of file RPCEfficiency.h.

Referenced by endRun(), and RPCEfficiency().

bool RPCEfficiency::EffSaveRootFile
private

Definition at line 185 of file RPCEfficiency.h.

Referenced by endRun(), and RPCEfficiency().

std::string RPCEfficiency::folderPath
private

Definition at line 179 of file RPCEfficiency.h.

Referenced by beginRun(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu1La[6]

Definition at line 131 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu1R2A

Definition at line 141 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu1R2B

Definition at line 140 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu1R2C

Definition at line 139 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu1R3A

Definition at line 138 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu1R3B

Definition at line 137 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu1R3C

Definition at line 136 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu2La[6]

Definition at line 132 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu2R2A

Definition at line 148 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu2R2B

Definition at line 147 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu2R2C

Definition at line 146 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu2R3A

Definition at line 145 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu2R3B

Definition at line 144 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu2R3C

Definition at line 143 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu3La[6]

Definition at line 133 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu3R2A

Definition at line 155 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu3R2B

Definition at line 154 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu3R2C

Definition at line 153 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu3R3A

Definition at line 152 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu3R3B

Definition at line 151 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::hGlobalResClu3R3C

Definition at line 150 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

bool RPCEfficiency::inclcsc
private

Definition at line 163 of file RPCEfficiency.h.

Referenced by analyze(), beginRun(), and RPCEfficiency().

bool RPCEfficiency::incldt
private

Definition at line 161 of file RPCEfficiency.h.

Referenced by analyze(), beginRun(), and RPCEfficiency().

bool RPCEfficiency::incldtMB4
private

Definition at line 162 of file RPCEfficiency.h.

Referenced by analyze(), beginRun(), and RPCEfficiency().

bool RPCEfficiency::inves
private

Definition at line 166 of file RPCEfficiency.h.

double RPCEfficiency::MaxD
private

Definition at line 170 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

double RPCEfficiency::MaxDrb4
private

Definition at line 171 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

std::map<int, std::map<std::string, MonitorElement*> > RPCEfficiency::meCollection
private

Definition at line 183 of file RPCEfficiency.h.

Referenced by analyze(), and beginRun().

double RPCEfficiency::MinCosAng
private

Definition at line 169 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

double RPCEfficiency::rangestrips
private

Definition at line 167 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

double RPCEfficiency::rangestripsRB4
private

Definition at line 168 of file RPCEfficiency.h.

Referenced by RPCEfficiency().

std::string RPCEfficiency::rollseff
private

Definition at line 181 of file RPCEfficiency.h.

std::map<CSCStationIndex,std::set<RPCDetId> > RPCEfficiency::rollstoreCSC

Definition at line 118 of file RPCEfficiency.h.

Referenced by analyze(), and beginRun().

std::map<DTStationIndex,std::set<RPCDetId> > RPCEfficiency::rollstoreDT

Definition at line 117 of file RPCEfficiency.h.

Referenced by analyze(), and beginRun().

edm::InputTag RPCEfficiency::RPCRecHitLabel_
private

Definition at line 177 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

MonitorElement* RPCEfficiency::statistics

Definition at line 124 of file RPCEfficiency.h.

Referenced by analyze(), and RPCEfficiency().

std::vector<int> RPCEfficiency::totalcounter
private

Definition at line 159 of file RPCEfficiency.h.