Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include <RecoLocalMuon/CSCRecHitD/src/CSCHitFromWireOnly.h>
00009 #include <RecoLocalMuon/CSCRecHitD/src/CSCWireHit.h>
00010
00011 #include <Geometry/CSCGeometry/interface/CSCLayer.h>
00012 #include <Geometry/CSCGeometry/interface/CSCLayerGeometry.h>
00013
00014 #include <DataFormats/CSCDigi/interface/CSCWireDigi.h>
00015
00016 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00017
00018 #include <iostream>
00019
00020
00021 CSCHitFromWireOnly::CSCHitFromWireOnly( const edm::ParameterSet& ps ) : recoConditions_(0){
00022
00023 deltaT = ps.getParameter<int>("CSCWireClusterDeltaT");
00024
00025 }
00026
00027
00028 CSCHitFromWireOnly::~CSCHitFromWireOnly(){}
00029
00030
00031 std::vector<CSCWireHit> CSCHitFromWireOnly::runWire( const CSCDetId& id, const CSCLayer* layer, const CSCWireDigiCollection::Range& rwired ) {
00032
00033 std::vector<CSCWireHit> hitsInLayer;
00034
00035 id_ = id;
00036 layer_ = layer;
00037 layergeom_ = layer->geometry();
00038 bool any_digis = true;
00039 int n_wgroup = 0;
00040
00041
00042
00043 for ( CSCWireDigiCollection::const_iterator it = rwired.first; it != rwired.second; ++it ) {
00044
00045 const CSCWireDigi wdigi = *it;
00046
00047 if(isDeadWG( id, wdigi.getWireGroup())){
00048 continue;
00049 }
00050 if ( any_digis ) {
00051 any_digis = false;
00052 makeWireCluster( wdigi );
00053 n_wgroup = 1;
00054 } else {
00055 if ( !addToCluster( wdigi ) ) {
00056
00057 float whit_pos = findWireHitPosition();
00058 bool deadWG_left = isDeadWG( id, wire_in_cluster.at(0) -1 );
00059 bool deadWG_right = isDeadWG( id, wire_in_cluster.at(wire_in_cluster.size()-1) + 1);
00060 short int aDeadWG = 0;
00061 if(!deadWG_left && !deadWG_right){
00062 aDeadWG = 0;
00063 }
00064 else if(deadWG_left && deadWG_right){
00065 aDeadWG = 255;
00066 }
00067 else{
00068 if(deadWG_left){
00069 aDeadWG = wire_in_cluster.at(0) -1;
00070 }
00071 else{
00072 aDeadWG = wire_in_cluster.at(wire_in_cluster.size()-1) + 1;
00073 }
00074 }
00075
00076 std::vector <int> timeBinsOn=wire_cluster[n_wgroup/2].getTimeBinsOn();
00077
00078 CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn );
00079 hitsInLayer.push_back( whit );
00080 makeWireCluster( wdigi );
00081 n_wgroup = 1;
00082 } else {
00083 n_wgroup++;
00084 }
00085 }
00086
00087 if ( rwired.second - it == 1) {
00088 float whit_pos = findWireHitPosition();
00089 bool deadWG_left = isDeadWG( id, wire_in_cluster.at(0) -1 );
00090 bool deadWG_right = isDeadWG( id, wire_in_cluster.at(wire_in_cluster.size()-1) + 1);
00091 short int aDeadWG = 0;
00092 if(!deadWG_left && !deadWG_right){
00093 aDeadWG = 0;
00094 }
00095 else if(deadWG_left && deadWG_right){
00096 aDeadWG = 255;
00097 }
00098 else{
00099 if(deadWG_left){
00100 aDeadWG = wire_in_cluster.at(0) -1;
00101 }
00102 else{
00103 aDeadWG = wire_in_cluster.at(wire_in_cluster.size()-1) + 1;
00104 }
00105 }
00106 std::vector <int> timeBinsOn=wire_cluster[n_wgroup/2].getTimeBinsOn();
00108
00109 CSCWireHit whit(id, whit_pos, wire_in_clusterAndBX, theTime, aDeadWG, timeBinsOn );
00110 hitsInLayer.push_back( whit );
00111 n_wgroup++;
00112 }
00113 }
00114
00116
00117
00118
00119
00120
00121
00122 return hitsInLayer;
00123 }
00124
00125
00126 void CSCHitFromWireOnly::makeWireCluster(const CSCWireDigi & digi) {
00127 wire_cluster.clear();
00128 wire_in_cluster.clear();
00129 wire_in_clusterAndBX.clear();
00130 theLastChannel = digi.getWireGroup();
00131 theTime = digi.getTimeBin();
00132 wire_cluster.push_back( digi );
00133 }
00134
00135
00136 bool CSCHitFromWireOnly::addToCluster(const CSCWireDigi & digi) {
00137
00138
00139 int iwg = digi.getWireGroup();
00140
00141 if ( iwg == theLastChannel ){
00142 return true;
00143 }
00144 else{
00145 if ( (iwg == theLastChannel+1) && (abs(digi.getTimeBin()-theTime)<= deltaT) ) {
00146 theLastChannel = iwg;
00147 wire_cluster.push_back( digi );
00148 return true;
00149 }
00150 }
00151
00152 return false;
00153 }
00154
00155
00156
00157
00158
00159
00160 float CSCHitFromWireOnly::findWireHitPosition() {
00161
00162
00163
00164
00165 float y = 0.0;
00166
00167 for ( unsigned i = 0; i < wire_cluster.size(); ++i ) {
00168 CSCWireDigi wdigi = wire_cluster[i];
00169 int wgroup = wdigi.getWireGroup();
00170 wire_in_cluster.push_back( wgroup );
00171 int wgroupAndBX = wdigi.getBXandWireGroup();
00172
00173 wire_in_clusterAndBX.push_back( wgroupAndBX );
00174 y += float( wgroup );
00175 }
00176
00177 float wiregpos = y /wire_cluster.size() ;
00178
00179 return wiregpos;
00180
00181 }
00182
00183 bool CSCHitFromWireOnly::isDeadWG(const CSCDetId& id, int WG){
00184
00185 const std::bitset<112> & deadWG = recoConditions_->badWireWord( id );
00186 bool isDead = false;
00187 if(WG>-1 && WG<112){
00188 isDead = deadWG.test(WG);
00189 }
00190 return isDead;
00191 }