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 CSCHitFromWireOnly::CSCHitFromWireOnly(const edm::ParameterSet& ps) : recoConditions_(nullptr) {
21  deltaT = ps.getParameter<int>("CSCWireClusterDeltaT");
22  useReducedWireTime = ps.getParameter<bool>("CSCUseReducedWireTimeWindow");
23  wireTimeWindow_low = ps.getParameter<int>("CSCWireTimeWindowLow");
24  wireTimeWindow_high = ps.getParameter<int>("CSCWireTimeWindowHigh");
25 
26  //clusterSize = ps.getParameter<int>("CSCWireClusterMaxSize");
27 }
28 
30 
31 std::vector<CSCWireHit> CSCHitFromWireOnly::runWire(const CSCDetId& id,
32  const CSCLayer* layer,
33  const CSCWireDigiCollection::Range& rwired) {
34  std::vector<CSCWireHit> hitsInLayer;
35 
36  id_ = id;
37  layer_ = layer;
38  layergeom_ = layer->geometry();
39  bool any_digis = true;
40  int n_wgroup = 0;
41 
42  // Loop over wire digi collection
43  for (CSCWireDigiCollection::const_iterator it = rwired.first; it != rwired.second; ++it) {
44  const CSCWireDigi wdigi = *it;
45 
46  if (isDeadWG(id, wdigi.getWireGroup())) {
47  continue;
48  }
49  if (any_digis) {
50  any_digis = false;
51  makeWireCluster(wdigi);
52  n_wgroup = 1;
53  } else {
54  if (!addToCluster(wdigi)) {
55  // Make Wire Hit from cluster, delete old cluster and start new one
56  float whit_pos = findWireHitPosition();
57  bool deadWG_left = isDeadWG(id, wire_in_cluster.at(0) - 1);
58  bool deadWG_right = isDeadWG(id, wire_in_cluster.at(wire_in_cluster.size() - 1) + 1);
59  short int aDeadWG = 0;
60  if (!deadWG_left && !deadWG_right) {
61  aDeadWG = 0;
62  } else if (deadWG_left && deadWG_right) {
63  aDeadWG = 255;
64  } else {
65  if (deadWG_left) {
66  aDeadWG = wire_in_cluster.at(0) - 1;
67  } else {
68  aDeadWG = wire_in_cluster.at(wire_in_cluster.size() - 1) + 1;
69  }
70  }
71  // 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.
72  std::vector<int> timeBinsOn = wire_cluster[n_wgroup / 2].getTimeBinsOn();
73  //CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, isDeadWGAround, timeBinsOn );
74  CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn);
75 
76  if (!useReducedWireTime) {
77  hitsInLayer.push_back(whit);
79  hitsInLayer.push_back(whit);
80  }
81 
82  makeWireCluster(wdigi);
83  n_wgroup = 1;
84  } else {
85  n_wgroup++;
86  }
87  }
88  // Don't forget to fill last wire hit !!!
89  if (rwired.second - it == 1) {
90  float whit_pos = findWireHitPosition();
91  bool deadWG_left = isDeadWG(id, wire_in_cluster.at(0) - 1);
92  bool deadWG_right = isDeadWG(id, wire_in_cluster.at(wire_in_cluster.size() - 1) + 1);
93  short int aDeadWG = 0;
94  if (!deadWG_left && !deadWG_right) {
95  aDeadWG = 0;
96  } else if (deadWG_left && deadWG_right) {
97  aDeadWG = 255;
98  } else {
99  if (deadWG_left) {
100  aDeadWG = wire_in_cluster.at(0) - 1;
101  } else {
102  aDeadWG = wire_in_cluster.at(wire_in_cluster.size() - 1) + 1;
103  }
104  }
105  std::vector<int> timeBinsOn = wire_cluster[n_wgroup / 2].getTimeBinsOn();
107  //CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, isDeadWGAround, timeBinsOn );
108  CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn);
109 
110  if (!useReducedWireTime) {
111  hitsInLayer.push_back(whit);
113  hitsInLayer.push_back(whit);
114  }
115 
116  n_wgroup++;
117  }
118  }
119 
121  /*
122  for(std::vector<CSCWireHit>::const_iterator itWHit=hitsInLayer.begin(); itWHit!=hitsInLayer.end(); ++itWHit){
123  (*itWHit).print();
124  }
125  */
126 
127  return hitsInLayer;
128 }
129 
131  wire_cluster.clear();
132  wire_in_cluster.clear();
133  wire_in_clusterAndBX.clear();
134  theLastChannel = digi.getWireGroup();
135  theTime = digi.getTimeBin();
136  wire_cluster.push_back(digi);
137 }
138 
140  int iwg = digi.getWireGroup();
141 
142  if (iwg == theLastChannel) {
143  return true; // Same wire group but different tbin -> ignore
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 /* findWireHitPosition
156  *
157  * This position is expressed in terms of wire #... is a float since it may be a fraction.
158  */
160  // Again use center of mass to determine position of wire hit
161  // To do so, need to know wire spacing and # of wires
162 
163  float y = 0.0;
164 
165  for (unsigned i = 0; i < wire_cluster.size(); ++i) {
166  CSCWireDigi wdigi = wire_cluster[i];
167  int wgroup = wdigi.getWireGroup();
168  wire_in_cluster.push_back(wgroup);
169  int wgroupAndBX = wdigi.getBXandWireGroup();
170  //std::cout << " wgroupAndBX: " << std::hex << wgroupAndBX << std::dec << std::endl;
171  wire_in_clusterAndBX.push_back(wgroupAndBX);
172  y += float(wgroup);
173  }
174 
175  float wiregpos = y / wire_cluster.size();
176 
177  return wiregpos;
178 }
179 
180 bool CSCHitFromWireOnly::isDeadWG(const CSCDetId& id, int WG) {
181  const std::bitset<112>& deadWG = recoConditions_->badWireWord(id);
182  bool isDead = false;
183  if (WG > -1 && WG < 112) {
184  isDead = deadWG.test(WG);
185  }
186  return isDead;
187 }
CSCHitFromWireOnly::isDeadWG
bool isDeadWG(const CSCDetId &id, int WG)
Definition: CSCHitFromWireOnly.cc:180
CSCHitFromWireOnly::~CSCHitFromWireOnly
~CSCHitFromWireOnly()
Definition: CSCHitFromWireOnly.cc:29
CSCWireHit.h
DDAxes::y
CSCHitFromWireOnly::makeWireCluster
void makeWireCluster(const CSCWireDigi &digi)
Definition: CSCHitFromWireOnly.cc:130
CSCHitFromWireOnly::wireTimeWindow_high
int wireTimeWindow_high
Definition: CSCHitFromWireOnly.h:69
mps_fire.i
i
Definition: mps_fire.py:355
CSCWireHit
Definition: CSCWireHit.h:17
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
CSCWireDigi::getWireGroup
int getWireGroup() const
default
Definition: CSCWireDigi.h:22
CSCWireDigi.h
CSCRecoConditions::badWireWord
const std::bitset< 112 > & badWireWord(const CSCDetId &id) const
Get bad wiregroup word.
Definition: CSCRecoConditions.cc:162
CSCLayer
Definition: CSCLayer.h:24
CSCHitFromWireOnly::addToCluster
bool addToCluster(const CSCWireDigi &digi)
Definition: CSCHitFromWireOnly.cc:139
CSCHitFromWireOnly::wire_in_clusterAndBX
std::vector< int > wire_in_clusterAndBX
Definition: CSCHitFromWireOnly.h:64
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
CSCHitFromWireOnly::CSCHitFromWireOnly
CSCHitFromWireOnly(const edm::ParameterSet &ps)
Definition: CSCHitFromWireOnly.cc:20
CSCHitFromWireOnly::runWire
std::vector< CSCWireHit > runWire(const CSCDetId &id, const CSCLayer *layer, const CSCWireDigiCollection::Range &rwired)
Definition: CSCHitFromWireOnly.cc:31
CSCHitFromWireOnly::wire_in_cluster
std::vector< int > wire_in_cluster
Definition: CSCHitFromWireOnly.h:60
CSCLayerGeometry.h
CSCLayer::geometry
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
CSCHitFromWireOnly.h
CSCHitFromWireOnly::theTime
int theTime
Definition: CSCHitFromWireOnly.h:62
edm::ParameterSet
Definition: ParameterSet.h:36
CSCWireDigi::getTimeBin
int getTimeBin() const
return first tbin ON number
Definition: CSCWireDigi.cc:35
CSCWireDigi
Definition: CSCWireDigi.h:14
CSCDetId
Definition: CSCDetId.h:26
CSCHitFromWireOnly::useReducedWireTime
bool useReducedWireTime
Definition: CSCHitFromWireOnly.h:67
CSCHitFromWireOnly::recoConditions_
const CSCRecoConditions * recoConditions_
Hold pointer to current conditions data.
Definition: CSCHitFromWireOnly.h:73
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CSCHitFromWireOnly::wire_cluster
std::vector< CSCWireDigi > wire_cluster
Definition: CSCHitFromWireOnly.h:59
CSCLayer.h
CSCHitFromWireOnly::deltaT
int deltaT
To fill BX + wiregroup in CSCWireHit.
Definition: CSCHitFromWireOnly.h:66
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
CSCHitFromWireOnly::theLastChannel
int theLastChannel
Definition: CSCHitFromWireOnly.h:63
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
CSCHitFromWireOnly::layer_
const CSCLayer * layer_
Definition: CSCHitFromWireOnly.h:53
CSCHitFromWireOnly::id_
CSCDetId id_
Definition: CSCHitFromWireOnly.h:52
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
CSCHitFromWireOnly::layergeom_
const CSCLayerGeometry * layergeom_
Definition: CSCHitFromWireOnly.h:54
CSCHitFromWireOnly::findWireHitPosition
float findWireHitPosition()
Definition: CSCHitFromWireOnly.cc:159
CSCHitFromWireOnly::wireTimeWindow_low
int wireTimeWindow_low
Definition: CSCHitFromWireOnly.h:68
CSCWireDigi::getBXandWireGroup
int getBXandWireGroup() const
Definition: CSCWireDigi.h:27