test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  //clusterSize = ps.getParameter<int>("CSCWireClusterMaxSize");
25 }
26 
27 
29 
30 
31 std::vector<CSCWireHit> CSCHitFromWireOnly::runWire( const CSCDetId& id, const CSCLayer* layer, const CSCWireDigiCollection::Range& rwired ) {
32 
33  std::vector<CSCWireHit> hitsInLayer;
34 
35  id_ = id;
36  layer_ = layer;
37  layergeom_ = layer->geometry();
38  bool any_digis = true;
39  int n_wgroup = 0;
40 
41 
42  // Loop over wire digi collection
43  for ( CSCWireDigiCollection::const_iterator it = rwired.first; it != rwired.second; ++it ) {
44 
45  const CSCWireDigi wdigi = *it;
46 
47  if(isDeadWG( id, wdigi.getWireGroup())){
48  continue;
49  }
50  if ( any_digis ) {
51  any_digis = false;
52  makeWireCluster( wdigi );
53  n_wgroup = 1;
54  } else {
55  if ( !addToCluster( wdigi ) ) {
56  // Make Wire Hit from cluster, delete old cluster and start new one
57  float whit_pos = findWireHitPosition();
58  bool deadWG_left = isDeadWG( id, wire_in_cluster.at(0) -1 );
59  bool deadWG_right = isDeadWG( id, wire_in_cluster.at(wire_in_cluster.size()-1) + 1);
60  short int aDeadWG = 0;
61  if(!deadWG_left && !deadWG_right){
62  aDeadWG = 0;
63  }
64  else if(deadWG_left && deadWG_right){
65  aDeadWG = 255;
66  }
67  else{
68  if(deadWG_left){
69  aDeadWG = wire_in_cluster.at(0) -1;
70  }
71  else{
72  aDeadWG = wire_in_cluster.at(wire_in_cluster.size()-1) + 1;
73  }
74  }
75  // 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.
76  std::vector <int> timeBinsOn=wire_cluster[n_wgroup/2].getTimeBinsOn();
77  //CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, isDeadWGAround, timeBinsOn );
78  CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn );
79  hitsInLayer.push_back( whit );
80  makeWireCluster( wdigi );
81  n_wgroup = 1;
82  } else {
83  n_wgroup++;
84  }
85  }
86  // Don't forget to fill last wire hit !!!
87  if ( rwired.second - it == 1) {
88  float whit_pos = findWireHitPosition();
89  bool deadWG_left = isDeadWG( id, wire_in_cluster.at(0) -1 );
90  bool deadWG_right = isDeadWG( id, wire_in_cluster.at(wire_in_cluster.size()-1) + 1);
91  short int aDeadWG = 0;
92  if(!deadWG_left && !deadWG_right){
93  aDeadWG = 0;
94  }
95  else if(deadWG_left && deadWG_right){
96  aDeadWG = 255;
97  }
98  else{
99  if(deadWG_left){
100  aDeadWG = wire_in_cluster.at(0) -1;
101  }
102  else{
103  aDeadWG = wire_in_cluster.at(wire_in_cluster.size()-1) + 1;
104  }
105  }
106  std::vector <int> timeBinsOn=wire_cluster[n_wgroup/2].getTimeBinsOn();
108  //CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, isDeadWGAround, timeBinsOn );
109  CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn );
110  hitsInLayer.push_back( whit );
111  n_wgroup++;
112  }
113  }
114 
116  /*
117  for(std::vector<CSCWireHit>::const_iterator itWHit=hitsInLayer.begin(); itWHit!=hitsInLayer.end(); ++itWHit){
118  (*itWHit).print();
119  }
120  */
121 
122  return hitsInLayer;
123 }
124 
125 
127  wire_cluster.clear();
128  wire_in_cluster.clear();
129  wire_in_clusterAndBX.clear();
130  theLastChannel = digi.getWireGroup();
131  theTime = digi.getTimeBin();
132  wire_cluster.push_back( digi );
133 }
134 
135 
137 
138 
139  int iwg = digi.getWireGroup();
140 
141  if ( iwg == theLastChannel ){
142  return true; // Same wire group but different tbin -> ignore
143  }
144  else{
145  if ( (iwg == theLastChannel+1) && (abs(digi.getTimeBin()-theTime)<= deltaT) ) {
146  theLastChannel = iwg;
147  wire_cluster.push_back( digi );
148  return true;
149  }
150  }
151 
152  return false;
153 }
154 
155 
156 /* findWireHitPosition
157  *
158  * This position is expressed in terms of wire #... is a float since it may be a fraction.
159  */
161 
162  // Again use center of mass to determine position of wire hit
163  // To do so, need to know wire spacing and # of wires
164 
165  float y = 0.0;
166 
167  for ( unsigned i = 0; i < wire_cluster.size(); ++i ) {
168  CSCWireDigi wdigi = wire_cluster[i];
169  int wgroup = wdigi.getWireGroup();
170  wire_in_cluster.push_back( wgroup );
171  int wgroupAndBX = wdigi.getBXandWireGroup();
172  //std::cout << " wgroupAndBX: " << std::hex << wgroupAndBX << std::dec << std::endl;
173  wire_in_clusterAndBX.push_back( wgroupAndBX );
174  y += float( wgroup );
175  }
176 
177  float wiregpos = y /wire_cluster.size() ;
178 
179  return wiregpos;
180 
181 }
182 
183 bool CSCHitFromWireOnly::isDeadWG(const CSCDetId& id, int WG){
184 
185  const std::bitset<112> & deadWG = recoConditions_->badWireWord( id );
186  bool isDead = false;
187  if(WG>-1 && WG<112){
188  isDead = deadWG.test(WG);
189  }
190  return isDead;
191 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
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:24
CSCHitFromWireOnly(const edm::ParameterSet &ps)
std::vector< CSCWireHit > runWire(const CSCDetId &id, const CSCLayer *layer, const CSCWireDigiCollection::Range &rwired)
std::vector< CSCWireDigi >::const_iterator const_iterator
std::vector< int > wire_in_clusterAndBX
int getTimeBin() const
return first tbin ON number
Definition: CSCWireDigi.cc:37
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:29
bool isDeadWG(const CSCDetId &id, int WG)
std::vector< CSCWireDigi > wire_cluster