CMS 3D CMS Logo

CSCRecHitDBuilder.cc
Go to the documentation of this file.
1 // This is CSCRecHitDBuilder.cc
2 
10 
14 
16 
23 
26 
27 #include <iostream>
28 #include <cassert>
29 
31 
32  // Receives ParameterSet percolated down from EDProducer
33 
34  useCalib = ps.getParameter<bool>("CSCUseCalibrations");
35  stripWireDeltaT = ps.getParameter<int>("CSCstripWireDeltaTime");
36 
39  make2DHits_ = new CSCMake2DRecHit( ps );
40 }
41 
42 
44  delete hitsFromStripOnly_;
45  delete hitsFromWireOnly_;
46  delete make2DHits_;
47 }
48 
49 
51  CSCRecHit2DCollection& oc ) {
52  LogTrace("CSCRecHitDBuilder") << "[CSCRecHitDBuilder] build entered";
53 
54  if ( !geom_ ) throw cms::Exception("MissingGeometry") << "[CSCRecHitDBuilder::getLayer] Missing geometry" << std::endl;
55 
56 
57 
58 
59  // create 2-D hits by looking at superposition of strip and wire hit in a layer
60  //
61  // N.B. I've sorted the hits from layer 1-6 always, so can test if there are "holes",
62  // that is layers without hits for a given chamber.
63 
64  // Vector to store rechit within layer
65  std::vector<CSCRecHit2D> hitsInLayer;
66 
67  int layer_idx = 0;
68  int hits_in_layer = 0;
69  CSCDetId old_id;
70 
71 
72  for ( CSCStripDigiCollection::DigiRangeIterator it = stripdc->begin(); it != stripdc->end(); ++it ){
73  const CSCDetId& id = (*it).first;
74  const CSCLayer* layer = getLayer( id );
75  const CSCStripDigiCollection::Range& rstripd = (*it).second;
76 
77  // Skip if no strip digis in this layer
78  if ( rstripd.second == rstripd.first ) continue;
79 
80  const CSCDetId& sDetId = id;
81 
82  // This is used to test for gaps in layers and needs to be initialized here
83  if ( layer_idx == 0 ) {
84  old_id = sDetId;
85  }
86 
87 
88  CSCDetId compId = sDetId;
89  CSCWireDigiCollection::Range rwired = wiredc->get( sDetId );
90  // Skip if no wire digis in this layer
91  // But for ME11, real wire digis are labelled as belonging to ME1b, so that's where ME1a must look
92  // (We try ME1a - above - anyway, because simulated wire digis are labelled as ME1a.)
93  if ( rwired.second == rwired.first ) {
94  if ( sDetId.station()!=1 || sDetId.ring()!=4 ){
95  continue; // not ME1a, skip to next layer
96  }
97  // So if ME1a has no wire digis (always the case for data) make the
98  // wire digi ID point to ME1b. This is what is compared to the
99  // strip digi ID below (and not used anywhere else).
100  // Later, rechits use the strip digi ID for construction.
101 
102  // It is ME1a but no wire digis there, so try ME1b...
103  int endcap = sDetId.endcap();
104  int chamber = sDetId.chamber();
105  int layer = sDetId.layer();
106  CSCDetId idw( endcap, 1, 1, chamber, layer ); // Set idw to same layer in ME1b
107  compId = idw;
108  rwired = wiredc->get( compId );
109  }
110 
111  // Fill bad channel bitsets for this layer
113 
114  // Build strip hits for this layer
115  std::vector<CSCStripHit> const & cscStripHit = hitsFromStripOnly_->runStrip( id, layer, rstripd);
116 
117  if (cscStripHit.empty()) continue;
118 
119  hitsInLayer.clear();
120  hits_in_layer = 0;
121 
122 
123  // now build collection of wire only hits !
124  std::vector<CSCWireHit> const & cscWireHit = hitsFromWireOnly_->runWire(compId, layer, rwired);
125 
126 
127 
128  // Build 2D hit for all possible strip-wire pairs
129  // overlapping within this layer
130 
131  LogTrace("CSCRecHitBuilder")<< "[CSCRecHitDBuilder] found " << cscStripHit.size() << " strip and "
132  << cscWireHit.size() << " wire hits in layer " << sDetId;
133 
134  for (auto const & s_hit : cscStripHit) {
135  for (auto const & w_hit : cscWireHit) {
136  CSCRecHit2D rechit = make2DHits_->hitFromStripAndWire(sDetId, layer, w_hit, s_hit);
137 
138  bool isInFiducial = make2DHits_->isHitInFiducial( layer, rechit );
139  if ( isInFiducial ) {
140  hitsInLayer.push_back( rechit );
141  hits_in_layer++;
142  }
143  }
144  }
145 
146 
147 
148 
149  LogTrace("CSCRecHitDBuilder") << "[CSCRecHitDBuilder] " << hits_in_layer << " rechits found in layer " << sDetId;
150  // std::cout << "[CSCRecHitDBuilder] " << hits_in_layer << " rechits found in layer " << sDetId << std::endl;
151 
152  // output vector of 2D rechits to collection
153  if (hits_in_layer > 0) {
154  oc.put( sDetId, hitsInLayer.begin(), hitsInLayer.end() );
155  hitsInLayer.clear();
156  }
157  hits_in_layer = 0;
158  layer_idx++;
159  old_id = sDetId;
160  }
161 
162  LogTrace("CSCRecHitDBuilder") << "[CSCRecHitDBuilder] " << oc.size() << " 2d rechits created in this event.";
163 
164 }
165 
166 
168  return geom_->layer(detId);
169 }
170 
171 
176  make2DHits_->setConditions( reco );
177 }
int chamber() const
Definition: CSCDetId.h:68
T getParameter(std::string const &) const
const CSCGeometry * geom_
void setConditions(CSCRecoConditions *reco)
#define nullptr
std::vector< CSCStripHit > runStrip(const CSCDetId &id, const CSCLayer *layer, const CSCStripDigiCollection::Range &rstripd)
int layer() const
Definition: CSCDetId.h:61
void setConditions(const CSCRecoConditions *reco)
Pass pointer to conditions data onwards.
const CSCLayer * getLayer(const CSCDetId &detId)
int endcap() const
Definition: CSCDetId.h:93
void build(const CSCStripDigiCollection *stripds, const CSCWireDigiCollection *wireds, CSCRecHit2DCollection &oc)
void setConditions(const CSCRecoConditions *reco)
void fillBadChannelWords(const CSCDetId &id)
fill bad strip & bad wiregroup bitsets from conditions data
CSCHitFromWireOnly * hitsFromWireOnly_
CSCRecoConditions * recoConditions_
bool isHitInFiducial(const CSCLayer *layer, const CSCRecHit2D &rh)
Test if rechit is in fiducial volume.
#define LogTrace(id)
CSCHitFromStripOnly * hitsFromStripOnly_
int ring() const
Definition: CSCDetId.h:75
std::vector< CSCWireHit > runWire(const CSCDetId &id, const CSCLayer *layer, const CSCWireDigiCollection::Range &rwired)
CSCRecHitDBuilder(const edm::ParameterSet &ps)
CSCRecHit2D hitFromStripAndWire(const CSCDetId &id, const CSCLayer *layer, const CSCWireHit &wHit, const CSCStripHit &sHit)
Make 2D hits when have both wire and strip hit available in same layer.
void setConditions(const CSCRecoConditions *reco)
CSCMake2DRecHit * make2DHits_
fixed size matrix
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:139
int station() const
Definition: CSCDetId.h:86
std::pair< const_iterator, const_iterator > Range