Go to the documentation of this file.00001 #include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
00002 #include <iostream>
00003
00004 CSCRecHit2D::CSCRecHit2D() :
00005 theTpeak( -999. ),
00006 thePositionWithinStrip(-999.),
00007 theErrorWithinStrip(-999.),
00008 theEnergyDeposit( -994. ),
00009 theQuality( 0 ),
00010 theScaledWireTime( 0 ),
00011 theBadStrip( 0 ),
00012 theBadWireGroup( 0 ),
00013 nStrips_(0),
00014 nWireGroups_(0),
00015 nTimeBins_(0),
00016 theLocalPosition(0.,0.),
00017 theLocalError(0.,0.,0.)
00018 {
00019 for ( unsigned int i=0; i< MAXSTRIPS; i++) theStrips_[i]=0;
00020 for ( unsigned int i=0; i< MAXSTRIPS; i++)
00021 for ( unsigned int j=0; j< MAXTIMEBINS; j++)
00022 theADCs_[i*MAXTIMEBINS+j]=0;
00023 }
00024
00025 CSCRecHit2D::CSCRecHit2D( const CSCDetId& id,
00026 const LocalPoint& pos,
00027 const LocalError& err,
00028 const ChannelContainer& channels,
00029 const ADCContainer& adcs,
00030 const ChannelContainer& wgroups,
00031 float tpeak,
00032 float posInStrip,
00033 float errInStrip,
00034 int quality, short int badStrip, short int badWireGroup,
00035 int scaledWireTime,
00036 float energyDeposit):
00037 RecHit2DLocalPos( id ),
00038 theTpeak( tpeak ),
00039 thePositionWithinStrip( posInStrip ),
00040 theErrorWithinStrip( errInStrip ),
00041 theEnergyDeposit( energyDeposit ),
00042 theQuality( quality ),
00043 theScaledWireTime ( scaledWireTime ),
00044 theBadStrip( badStrip ), theBadWireGroup( badWireGroup ),
00045 theLocalPosition( pos ),
00046 theLocalError( err )
00047 {
00048 nStrips_=channels.size();
00049 nWireGroups_=wgroups.size();
00050
00051 if ( nStrips_ > MAXSTRIPS ) {
00052 std::cout << "CSCRecHit2D: not enough strips in DataFormat! " << unsigned(nStrips_) << std::endl;
00053 nStrips_=MAXSTRIPS;
00054 }
00055
00056 for ( unsigned int i=0; i< MAXSTRIPS; i++) theStrips_[i]=0;
00057 for ( unsigned int i=0; i< MAXSTRIPS; i++) theL1APhaseBits_[i]=0;
00058 for ( unsigned int i=0; i< MAXSTRIPS; i++)
00059 for ( unsigned int j=0; j< MAXTIMEBINS; j++)
00060 theADCs_[i*MAXTIMEBINS+j]=0;
00061
00062
00063 for ( unsigned int i=0; i<nStrips_; i++) {
00064 theStrips_[i]=channels[i] & 0x000000FF;
00065 theL1APhaseBits_[i]=channels[i] & 0x0000FF00;
00066 }
00067 if (nWireGroups_>0) {
00068
00069 hitWire_=wgroups[nWireGroups_/2] & 0x0000FFFF;
00070 theWGroupsBX_= (wgroups[nWireGroups_/2] >> 16)& 0x0000FFFF;
00071 }
00072 else {
00073 hitWire_=0;
00074 theWGroupsBX_=0;
00075 }
00076 ADCContainer tmp(adcs);
00077 nTimeBins_=tmp.size()/nStrips_;
00078 unsigned int k=0;
00079 for ( unsigned int i=0; i<nStrips_; i++)
00080 for ( unsigned int j=0; j<nTimeBins_; j++) {
00081 theADCs_[i*MAXTIMEBINS+j]=tmp[k];
00082 k++;
00083 }
00084 }
00085
00086 CSCRecHit2D::~CSCRecHit2D() {}
00087
00088 bool CSCRecHit2D::sharesInput(const TrackingRecHit *other, TrackingRecHit::SharedInputType what) const {
00089
00090
00091
00092
00093 CSCRecHit2D::SharedInputType cscWhat = static_cast<CSCRecHit2D::SharedInputType>(what);
00094 return sharesInput(other, cscWhat);
00095 }
00096
00097 bool CSCRecHit2D::sharesInput(const TrackingRecHit *other, CSCRecHit2D::SharedInputType what) const {
00098
00099
00100 if (other->geographicalId().subdetId() != MuonSubdetId::CSC) return false;
00101
00102
00103 const CSCRecHit2D *otherRecHit = static_cast<const CSCRecHit2D *>(other);
00104
00105 return sharesInput(otherRecHit, what);
00106 }
00107
00108
00109 bool CSCRecHit2D::sharesInput(const CSCRecHit2D *otherRecHit, CSCRecHit2D::SharedInputType what) const {
00110
00111
00112 if (geographicalId() != otherRecHit->geographicalId()) return false;
00113
00114
00115 if (nStrips() == 0 && otherRecHit->nStrips() == 0 && nWireGroups() == 0 && otherRecHit->nWireGroups() == 0) return true;
00116 if ((what == allWires || what == someWires) && nWireGroups() == 0 && otherRecHit->nWireGroups() == 0) return true;
00117 if ((what == allStrips || what == someStrips) && nStrips() == 0 && otherRecHit->nStrips() == 0) return true;
00118
00119
00120 if ((what == all || what == allWires) && nWireGroups() != otherRecHit->nWireGroups()) return false;
00121
00122
00123 if ((what == all || what == allStrips) && nStrips() != otherRecHit->nStrips()) return false;
00124
00125 bool foundWire = false;
00126
00127 if (what != allStrips && what != someStrips) {
00128
00129 if ( hitWire() != otherRecHit->hitWire() ) return false;
00130 }
00131
00132
00133 bool foundStrip = false;
00134 if (what != allWires && what != someWires) {
00135 for (unsigned int i=0; i< nStrips(); i++) {
00136 bool found = false;
00137 for (unsigned int j=0; j< nStrips(); j++) {
00138
00139 if(cscDetId().channel(channels(i))==otherRecHit->cscDetId().channel(otherRecHit->channels(j))){
00140 if (what == some || what == someStrips) return true;
00141 else {
00142 found = true;
00143 foundStrip = true;
00144 break;
00145 }
00146 }
00147 }
00148 if ((what == all || what == allStrips) && !found) return false;
00149 }
00150 if (what == someStrips && !foundStrip) return false;
00151 }
00152
00153
00154 if (!foundWire && !foundStrip) return false;
00155
00156
00157
00158
00159
00160
00161 return true;
00162 }
00163
00164
00165 void CSCRecHit2D::print() const {
00166 std::cout << "CSCRecHit in CSC Detector: " << cscDetId() << std::endl;
00167 std::cout << " local x = " << localPosition().x() << " +/- " << sqrt( localPositionError().xx() ) << " y = " << localPosition().y() << " +/- " << sqrt( localPositionError().yy() ) << std::endl;
00168
00169 std::cout << " tpeak " << theTpeak << " psoInStrip " << thePositionWithinStrip << " errorinstrip " << theErrorWithinStrip << " " << " qual " << theQuality << " wiretime " << theScaledWireTime << " tbs " << theBadStrip << " bwg " << theBadWireGroup << std::endl;
00170
00171 std::cout << " Channels: ";
00172 for (unsigned int i=0; i<nStrips(); i++) {std::cout << std::dec << channels(i) << " "
00173 << " (" << "HEX: " << std::hex << channels(i) << ")" << " ";
00174 }
00175 std::cout << std::endl;
00176
00177
00179 std::cout << " L1APhase: ";
00180 for (int i=0; i<(int)nStrips(); i++) {
00181 std::cout << "|";
00182 for (int k=0; k<8 ; k++){
00183 std::cout << ((channelsl1a(i) >> (15-k)) & 0x1) << " ";}
00184 std::cout << "| ";
00185 }
00186 std::cout << std::endl;
00187
00188 std::cout << "nWireGroups " << (int)nWireGroups() << " central wire " << hitWire_ <<std::endl;
00189 }
00190
00191
00192 std::ostream& operator<<(std::ostream& os, const CSCRecHit2D& rh) {
00193 os << "CSCRecHit2D: local x = " << rh.localPosition().x() << " +/- " << sqrt( rh.localPositionError().xx() ) <<
00194 " y = " << rh.localPosition().y() << " +/- " << sqrt( rh.localPositionError().yy() ) <<
00195 " in strip X = " << rh.positionWithinStrip() << " +/- = " << rh.errorWithinStrip()<<" quality = "<<rh.quality()<<"\n";
00196 os << " strip # : ";
00197 for(size_t iS =0;iS< rh.nStrips();++iS){
00198 os <<rh.channels(iS)<<" ";
00199 }
00200 os << "\n wire # : ";
00201
00202 os << "nWireGroups " << (int)rh.nWireGroups() << " central wire " << rh.hitWire() <<std::endl;
00203
00204 return os;
00205 }
00206
00207