CMS 3D CMS Logo

CSCHitFromWireOnly.cc
Go to the documentation of this file.
1 /* This is CSCHitFromWireOnly
2  *
3  * Finds wiregroup with hits, and fill in CSCWireHitCollection
4  * which includes only DetId and wiregroup #
5  *
6  */
7 
10 
13 
15 
17 
18 #include <iostream>
19 
20 
22 
23  deltaT = ps.getParameter<int>("CSCWireClusterDeltaT");
24  useReducedWireTime = ps.getParameter<bool>("CSCUseReducedWireTimeWindow");
25  wireTimeWindow_low = ps.getParameter<int>("CSCWireTimeWindowLow");
26  wireTimeWindow_high = ps.getParameter<int>("CSCWireTimeWindowHigh");
27 
28  //clusterSize = ps.getParameter<int>("CSCWireClusterMaxSize");
29 }
30 
31 
33 
34 
35 std::vector<CSCWireHit> CSCHitFromWireOnly::runWire( const CSCDetId& id, const CSCLayer* layer, const CSCWireDigiCollection::Range& rwired ) {
36 
37  std::vector<CSCWireHit> hitsInLayer;
38 
39  id_ = id;
40  layer_ = layer;
41  layergeom_ = layer->geometry();
42  bool any_digis = true;
43  int n_wgroup = 0;
44 
45 
46  // Loop over wire digi collection
47  for ( CSCWireDigiCollection::const_iterator it = rwired.first; it != rwired.second; ++it ) {
48 
49  const CSCWireDigi wdigi = *it;
50 
51  if(isDeadWG( id, wdigi.getWireGroup())){
52  continue;
53  }
54  if ( any_digis ) {
55  any_digis = false;
56  makeWireCluster( wdigi );
57  n_wgroup = 1;
58  } else {
59  if ( !addToCluster( wdigi ) ) {
60  // Make Wire Hit from cluster, delete old cluster and start new one
61  float whit_pos = findWireHitPosition();
62  bool deadWG_left = isDeadWG( id, wire_in_cluster.at(0) -1 );
63  bool deadWG_right = isDeadWG( id, wire_in_cluster.at(wire_in_cluster.size()-1) + 1);
64  short int aDeadWG = 0;
65  if(!deadWG_left && !deadWG_right){
66  aDeadWG = 0;
67  }
68  else if(deadWG_left && deadWG_right){
69  aDeadWG = 255;
70  }
71  else{
72  if(deadWG_left){
73  aDeadWG = wire_in_cluster.at(0) -1;
74  }
75  else{
76  aDeadWG = wire_in_cluster.at(wire_in_cluster.size()-1) + 1;
77  }
78  }
79  // Set time bins for wire hit as the time bins of the central wire digi, lower of central two if an even number of digis.
80  std::vector <int> timeBinsOn=wire_cluster[n_wgroup/2].getTimeBinsOn();
81  //CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, isDeadWGAround, timeBinsOn );
82  CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn );
83 
84  if (!useReducedWireTime) {
85  hitsInLayer.push_back( whit );
86  }
88  hitsInLayer.push_back( whit );
89  }
90 
91  makeWireCluster( wdigi );
92  n_wgroup = 1;
93  } else {
94  n_wgroup++;
95  }
96  }
97  // Don't forget to fill last wire hit !!!
98  if ( rwired.second - it == 1) {
99  float whit_pos = findWireHitPosition();
100  bool deadWG_left = isDeadWG( id, wire_in_cluster.at(0) -1 );
101  bool deadWG_right = isDeadWG( id, wire_in_cluster.at(wire_in_cluster.size()-1) + 1);
102  short int aDeadWG = 0;
103  if(!deadWG_left && !deadWG_right){
104  aDeadWG = 0;
105  }
106  else if(deadWG_left && deadWG_right){
107  aDeadWG = 255;
108  }
109  else{
110  if(deadWG_left){
111  aDeadWG = wire_in_cluster.at(0) -1;
112  }
113  else{
114  aDeadWG = wire_in_cluster.at(wire_in_cluster.size()-1) + 1;
115  }
116  }
117  std::vector <int> timeBinsOn=wire_cluster[n_wgroup/2].getTimeBinsOn();
119  //CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, isDeadWGAround, timeBinsOn );
120  CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn );
121 
122  if (!useReducedWireTime) {
123  hitsInLayer.push_back( whit );
124  }
126  hitsInLayer.push_back( whit );
127  }
128 
129  n_wgroup++;
130  }
131  }
132 
134  /*
135  for(std::vector<CSCWireHit>::const_iterator itWHit=hitsInLayer.begin(); itWHit!=hitsInLayer.end(); ++itWHit){
136  (*itWHit).print();
137  }
138  */
139 
140  return hitsInLayer;
141 }
142 
143 
145  wire_cluster.clear();
146  wire_in_cluster.clear();
147  wire_in_clusterAndBX.clear();
148  theLastChannel = digi.getWireGroup();
149  theTime = digi.getTimeBin();
150  wire_cluster.push_back( digi );
151 }
152 
153 
155 
156 
157  int iwg = digi.getWireGroup();
158 
159  if ( iwg == theLastChannel ){
160  return true; // Same wire group but different tbin -> ignore
161  }
162  else{
163  if ( (iwg == theLastChannel+1) && (abs(digi.getTimeBin()-theTime)<= deltaT) ) {
164  theLastChannel = iwg;
165  wire_cluster.push_back( digi );
166  return true;
167  }
168  }
169 
170  return false;
171 }
172 
173 
174 /* findWireHitPosition
175  *
176  * This position is expressed in terms of wire #... is a float since it may be a fraction.
177  */
179 
180  // Again use center of mass to determine position of wire hit
181  // To do so, need to know wire spacing and # of wires
182 
183  float y = 0.0;
184 
185  for ( unsigned i = 0; i < wire_cluster.size(); ++i ) {
186  CSCWireDigi wdigi = wire_cluster[i];
187  int wgroup = wdigi.getWireGroup();
188  wire_in_cluster.push_back( wgroup );
189  int wgroupAndBX = wdigi.getBXandWireGroup();
190  //std::cout << " wgroupAndBX: " << std::hex << wgroupAndBX << std::dec << std::endl;
191  wire_in_clusterAndBX.push_back( wgroupAndBX );
192  y += float( wgroup );
193  }
194 
195  float wiregpos = y /wire_cluster.size() ;
196 
197  return wiregpos;
198 
199 }
200 
201 bool CSCHitFromWireOnly::isDeadWG(const CSCDetId& id, int WG){
202 
203  const std::bitset<112> & deadWG = recoConditions_->badWireWord( id );
204  bool isDead = false;
205  if(WG>-1 && WG<112){
206  isDead = deadWG.test(WG);
207  }
208  return isDead;
209 }
T getParameter(std::string const &) const
#define nullptr
int deltaT
To fill BX + wiregroup in CSCWireHit.
std::vector< int > wire_in_cluster
void makeWireCluster(const CSCWireDigi &digi)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const CSCLayer * layer_
bool addToCluster(const CSCWireDigi &digi)
int getWireGroup() const
default
Definition: CSCWireDigi.h:22
CSCHitFromWireOnly(const edm::ParameterSet &ps)
std::vector< CSCWireHit > runWire(const CSCDetId &id, const CSCLayer *layer, const CSCWireDigiCollection::Range &rwired)
std::vector< DigiType >::const_iterator const_iterator
std::vector< int > wire_in_clusterAndBX
int getTimeBin() const
return first tbin ON number
Definition: CSCWireDigi.cc:35
std::pair< const_iterator, const_iterator > Range
const CSCRecoConditions * recoConditions_
Hold pointer to current conditions data.
const CSCLayerGeometry * layergeom_
const std::bitset< 112 > & badWireWord(const CSCDetId &id) const
Get bad wiregroup word.
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:47
int getBXandWireGroup() const
Definition: CSCWireDigi.h:27
bool isDeadWG(const CSCDetId &id, int WG)
std::vector< CSCWireDigi > wire_cluster