#include #include "TWireChecker.hh" #include "Stntuple/data/TCesCluster.hh" #include "Stntuple/data/TCprCluster.hh" #include "Stntuple/obj/TStnPhoton.hh" #include "Stntuple/obj/TStnClusterBlock.hh" using std::cout; using std::endl; ClassImp(TWireChecker) TWireChecker::TWireChecker():runNumber(-1) {} TWireChecker::~TWireChecker() {} bool TWireChecker::GoodCprCluster(TStnPhoton* pho, int nWire) { if(!pho) return false; if(pho->Detector()!=0) return false; int side = (pho->DetEta()<0 ? 0 : 1); int wedge = pho->PhiSeedIndex(); float cprz = pho->VertexZ() + 0.91*(pho->ZCes()-pho->VertexZ()); int ioff = (fabs(cprz)<122.0 ? 0 : 16); float cprx = -0.91*pho->XCes(); // Ces X is in -phi direction int cenWire = int(cprx/2.2225+8.0); int firstWire = cenWire - nWire/2; if(firstWire<0) firstWire=0; if(firstWire>15) firstWire=15; if(side==0 && ioff==16) firstWire = 15-firstWire; // readout backwards if(side==1 && ioff==0 ) firstWire = 15-firstWire; firstWire += ioff; //two z segments read out sequentially return GoodCprCluster(side,wedge,firstWire,nWire); } bool TWireChecker::GoodCprCluster(TCprCluster* clu) { if(!clu) return false; return GoodCprCluster(clu->Side(),clu->Wedge(), clu->FirstWire(),clu->NWires()); } bool TWireChecker::GoodCprCluster(Int_t is, Int_t iw, Int_t first, Int_t nWires) { if(runNumber<0) { cout << "Must set run number in TWireChecker" << endl; return false; } int minw=first; int maxw=first+nWires-1; if(runNumber<145700) { // before Jun 15, 2002 shutdown if(is==0) { if(iw==2) { if(minw<=31 && maxw>=31) return false; } else if(iw==6) { if(minw<=15 && maxw>=15) return false; } else if(iw==9) { if( !(maxw<16 || minw>31) ) return false; } else if(iw==14) { if(minw<=10 && maxw>=10) return false; } else if(iw==18) { if(minw<=5 && maxw>=5) return false; } else if(iw==19) { return false; } else if(iw==22) { if( !(maxw<0 || minw>2) ) return false; if(minw<=8 && maxw>=8 ) return false; if(minw<=12 && maxw>=12) return false; } } else { if(iw==0) { if(minw<=16 && maxw>=16) return false; } else if(iw==7) { if(minw<=17 && maxw>=17) return false; if(minw<=24 && maxw>=24) return false; if(minw<=29 && maxw>=29) return false; if(minw<=30 && maxw>=30) return false; if(minw<=31 && maxw>=31) return false; } else if(iw==15) { if(minw<=10 && maxw>=10) return false; if(minw<=11 && maxw>=11) return false; if(minw<=20 && maxw>=20) return false; } else if(iw==20) { if( !(maxw<8 || minw>15) ) return false; } } } else { if(is==0) { if(iw==3) { if(minw<=31 && maxw>=31) return false; } else if(iw==9) { if( !(maxw<16 || minw>31) ) return false; } else if(iw==14) { if(minw<=10 && maxw>=10) return false; } } else { if(iw==3) { if(minw<=31 && maxw>=31) return false; } else if(iw==5) { if( !(maxw<16 || minw>31) ) return false; } else if(iw==20) { if( !(maxw<10 || minw>15) ) return false; } } } return true; } bool TWireChecker::GoodCesCluster(TStnPhoton* pho, int nWire, int nStrip) { if(!pho) return false; if(fabs(pho->XCes())>30.0) return false; if(fabs(pho->ZCes())>250.0) return false; int side = (pho->DetEta()<0 ? 0 : 1); int wedge = pho->PhiSeedIndex(); float cesz = pho->ZCes(); float cesx = -pho->XCes(); bool qx = GoodCesClusterGeo(0,side,wedge,cesx,cesz,nWire,nStrip); bool qz = GoodCesClusterGeo(0,side,wedge,cesx,cesz,nWire,nStrip); return qx&&qz; } bool TWireChecker::GoodCesCluster(TStnPhoton* pho, TStnClusterBlock* club) { int ix = pho->CesWireCluster(); int iz = pho->CesStripCluster(); if(ix<0) return false; if(iz<0) return false; bool qx = GoodCesCluster(club->CesUnbCluster(ix)); bool qz = GoodCesCluster(club->CesUnbCluster(iz)); return qx&&qz; } bool TWireChecker::GoodCesClusterGeo(Int_t iv, Int_t is, Int_t iw, Float_t x, Float_t z, int nWire, int nStrip) { // split wires int ioff = (fabs(z)<122.0 ? 0 : 32); int cenWire = int(x/1.45484+16.0); int firstWire = cenWire - nWire/2; if(firstWire<0) firstWire=0; if(firstWire>31) firstWire=31; if(is==0) firstWire = 31-firstWire; // readout backwards firstWire += ioff; //two z segments read out sequentially int lastWire = cenWire + nWire/2; if(lastWire<0) lastWire=0; if(lastWire>31) lastWire=31; if(is==0) lastWire = 31-lastWire; // readout backwards lastWire += ioff; //two z segments read out sequentially bool qx = GoodCesCluster(0,is,iw,firstWire,lastWire-firstWire+1); //z cluster cenWire = int(fabs(z)-6.16/1.667); if(cenWire>=70) { cenWire = int(fabs(z)-121.183/2.007)+70; } firstWire = cenWire - nStrip/2; if(firstWire<0) firstWire=0; if(firstWire>127) firstWire=127; lastWire = cenWire + nStrip/2; if(lastWire<0) lastWire=0; if(lastWire>127) lastWire=127; bool qz = GoodCesCluster(1,is,iw,firstWire,lastWire-firstWire+1); return qx&&qz; } bool TWireChecker::GoodCesCluster(TCesCluster* clu) { if(!clu) return false; return GoodCesCluster(clu->View(),clu->Side(),clu->Wedge(), clu->FirstHit(),clu->NHit()); } bool TWireChecker::GoodCesCluster(Int_t iv, Int_t is, Int_t iw, Int_t first, Int_t nWires) { if(runNumber<0) { cout << "Must set run number in TWireChecker" << endl; return false; } // note that view=0 means wires, phi measurement, the offline convention // and the opposite of online and what is in dead channel database // bad wires for 2/2002 to 6/2003 int badWires0[86][5] = { 0, 0, 0, 16, 16, 0, 0, 2, 59, 59, 0, 0, 4, 47, 47, 0, 0, 4, 62, 63, 0, 0, 5, 47, 47, 0, 0, 7, 0, 1, 0, 0, 7, 29, 29, 0, 0, 7, 61, 63, 0, 0, 9, 13, 13, 0, 0, 10, 62, 62, 0, 0, 11, 54, 54, 0, 0, 14, 28, 28, 0, 0, 14, 52, 52, 0, 0, 16, 10, 11, 0, 0, 16, 14, 14, 0, 0, 16, 16, 16, 0, 0, 16, 18, 18, 0, 0, 16, 23, 23, 0, 0, 16, 27, 27, 0, 0, 16, 30, 30, 0, 0, 16, 50, 50, 0, 0, 18, 30, 30, 0, 0, 19, 0, 0, 0, 0, 19, 1, 1, 0, 0, 19, 60, 60, 0, 0, 21, 15, 15, 0, 0, 22, 47, 47, 0, 0, 23, 17, 17, 0, 0, 23, 33, 33, 0, 0, 23, 52, 52, 0, 1, 0, 16, 16, 0, 1, 1, 11, 11, 0, 1, 3, 0, 0, 0, 1, 3, 16, 16, 0, 1, 3, 20, 20, 0, 1, 3, 23, 23, 0, 1, 3, 25, 25, 0, 1, 3, 47, 47, 0, 1, 6, 4, 4, 0, 1, 7, 31, 31, 0, 1, 8, 31, 31, 0, 1, 10, 32, 32, 0, 1, 10, 62, 62, 0, 1, 11, 8, 8, 0, 1, 12, 15, 15, 0, 1, 12, 17, 17, 0, 1, 17, 48, 48, 0, 1, 17, 56, 56, 0, 1, 17, 60, 61, 0, 1, 18, 31, 31, 0, 1, 20, 27, 27, 0, 1, 23, 63, 63, 1, 0, 1, 2, 2, 1, 0, 1, 5, 5, 1, 0, 1, 6, 6, 1, 0, 1, 39, 39, 1, 0, 4, 0, 11, 1, 0, 4, 58, 63, 1, 0, 4, 101, 101, 1, 0, 4, 127, 127, 1, 0, 7, 4, 4, 1, 0, 10, 90, 90, 1, 0, 10, 122, 122, 1, 0, 10, 127, 127, 1, 0, 15, 63, 63, 1, 0, 16, 11, 11, 1, 0, 16, 15, 15, 1, 0, 16, 53, 53, 1, 0, 16, 69, 69, 1, 0, 18, 79, 79, 1, 0, 22, 31, 31, 1, 0, 23, 127, 127, 1, 1, 1, 3, 3, 1, 1, 1, 27, 27, 1, 1, 3, 15, 15, 1, 1, 3, 20, 20, 1, 1, 3, 23, 23, 1, 1, 4, 17, 17, 1, 1, 8, 31, 31, 1, 1, 8, 63, 63, 1, 1, 13, 112, 112, 1, 1, 14, 52, 52, 1, 1, 14, 94, 94, 1, 1, 14, 127, 127, 1, 1, 17, 127, 127, 1, 1, 20, 14, 14}; // bad wires for 6/2002 to 1/2003 int badWires1[87][5] = { 0, 0, 0, 16, 16, 0, 0, 1, 7, 7, 0, 0, 4, 47, 47, 0, 0, 4, 62, 62, 0, 0, 4, 63, 63, 0, 0, 5, 47, 47, 0, 0, 7, 0, 1, 0, 0, 7, 29, 29, 0, 0, 7, 61, 63, 0, 0, 9, 13, 13, 0, 0, 10, 62, 62, 0, 0, 11, 54, 54, 0, 0, 14, 28, 28, 0, 0, 14, 52, 52, 0, 0, 16, 10, 11, 0, 0, 16, 14, 14, 0, 0, 16, 16, 16, 0, 0, 16, 18, 18, 0, 0, 16, 23, 23, 0, 0, 16, 27, 27, 0, 0, 16, 30, 30, 0, 0, 16, 50, 50, 0, 0, 18, 30, 30, 0, 0, 19, 0, 1, 0, 0, 19, 60, 60, 0, 0, 21, 15, 15, 0, 0, 22, 47, 47, 0, 0, 23, 17, 17, 0, 0, 23, 33, 33, 0, 0, 23, 52, 52, 0, 1, 0, 16, 16, 0, 1, 1, 11, 11, 0, 1, 3, 0, 0, 0, 1, 3, 16, 16, 0, 1, 3, 20, 20, 0, 1, 3, 23, 23, 0, 1, 3, 25, 25, 0, 1, 3, 47, 47, 0, 1, 6, 4, 4, 0, 1, 7, 31, 31, 0, 1, 8, 31, 31, 0, 1, 10, 32, 32, 0, 1, 10, 62, 62, 0, 1, 11, 8, 8, 0, 1, 12, 15, 15, 0, 1, 12, 17, 17, 0, 1, 17, 48, 48, 0, 1, 17, 56, 56, 0, 1, 17, 60, 61, 0, 1, 18, 31, 31, 0, 1, 20, 27, 27, 0, 1, 23, 63, 63, 1, 0, 1, 2, 2, 1, 0, 1, 5, 5, 1, 0, 1, 6, 6, 1, 0, 1, 39, 39, 1, 0, 2, 59, 59, 1, 0, 4, 0,11, 1, 0, 4, 58, 63, 1, 0, 4, 101, 101, 1, 0, 4, 127, 127, 1, 0, 7, 4, 4, 1, 0, 10, 90, 90, 1, 0, 10, 122, 122, 1, 0, 10, 127, 127, 1, 0, 15, 63, 63, 1, 0, 16, 11, 11, 1, 0, 16, 15, 15, 1, 0, 16, 53, 53, 1, 0, 16, 69, 69, 1, 0, 18, 79, 79, 1, 0, 22, 31, 31, 1, 0, 23, 127, 127, 1, 1, 1, 3, 3, 1, 1, 1, 27, 27, 1, 1, 3, 15, 15, 1, 1, 3, 20, 20, 1, 1, 3, 23, 23, 1, 1, 4, 17, 17, 1, 1, 8, 31, 31, 1, 1, 8, 63, 63, 1, 1, 13, 112, 112, 1, 1, 14, 52, 52, 1, 1, 14, 94, 94, 1, 1, 14, 127, 127, 1, 1, 17, 127, 127, 1, 1, 20, 14, 14}; int minw=first; int maxw=first+nWires-1; if(runNumber<145700) { // before Jun 15, 2002 shutdown for(int i=0; i<86; i++) { if(iv==badWires0[i][0] && is==badWires0[i][1] && iw==badWires0[i][2]) { if(minw<=badWires0[i][4] && maxw>=badWires0[i][3]) return false; } } } else { for(int i=0; i<86; i++) { if(iv==badWires1[i][0] && is==badWires1[i][1] && iw==badWires1[i][2]) { if(minw<=badWires1[i][4] && maxw>=badWires1[i][3]) return false; } } } return true; }