// This file is PesCluster.cc /* history: 19 October 2000 Benn Tannenbaum changed the switch on case (layer) from 0 = west layer U or east layer V 1 = west layer V or east layer U to 1 = west layer U or east layer V 0 = west layer V or east layer U to reflect the proper labelling in the hardware. 09 March 2001 Benn Tannenbaum changed _clCentroidCM = centroid * STRIP_WIDTH; to _clCentroidCM = (centroid + 0.5)* STRIP_WIDTH; at Erik Brubaker's suggestion. This is needed because we need to be at the center of the strip, not the edge.... and to get there we need to add 0.5 of a strip. 26 April 2002 Erik Brubaker Added/unclobbered function to return the vector of PlugStrips. 06 Nov 2004 Brian Mohr Include event vertex information (including beam offset) Add tentative quality variable for dead, swap or edge clusters */ //----------------------- // This Class's Header -- //----------------------- #include "math.h" #include "CalorObjects/PesCluster.hh" //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "ErrorLogger_i/gERRLOG.hh" #include "CalorGeometry/PesGeometry.hh" #include "TBuffer.h" #include "CalorObjects/PlugStrip.hh" #include "CalorObjects/PlugStripColl.hh" #include // SET THE VERSION NUMBER : //const Version_t PesCluster::_VERSION = 2; const Version_t PesCluster::_VERSION = 3; // Default constructor : PesCluster::PesCluster() :_view(0.),_octant(0.), _clEnergy(0.),_clCentroid(0.),_clWidth(0.), _clNumStrips(0),_clLastStrip(0),_clSeedStrip(0), _clCentroidCM(0.),_clWidthCM(0.), _lineSlope(0.),_lineIntercept(0.),_lineInterceptErr(0.), _clusterZ(0.), _fiveOverNineRatio(0.),_chisq(-1.), _quality(0),version(-1) { _qEnergy.clear() ; } PesCluster::PesCluster(float energy, float centroid, float width, int numStrips, int lastStrip, int seed, float fiveOverNineRatio, std::vector qEnergy, float chisq) :_view(0.),_octant(0.), _clEnergy(energy),_clCentroid(centroid),_clWidth(width), _clNumStrips(numStrips),_clLastStrip(lastStrip),_clSeedStrip(seed), _clCentroidCM(0.),_clWidthCM(0.), _lineSlope(0.),_lineIntercept(0.),_lineInterceptErr(0.), _clusterZ(0.), _fiveOverNineRatio(fiveOverNineRatio), _chisq(chisq), _qEnergy(qEnergy), _quality(0.),version(-1) { PesGeometry pesGeometry(centroid, width); _clCentroidCM = pesGeometry.centroid(); _clWidthCM = pesGeometry.width(); } PesCluster::PesCluster(float energy, float centroid, float width,int numStrips, int lastStrip, int seed,float fiveOverNineRatio, std::vector qEnergy, float chisq,unsigned int quality) :_view(0.),_octant(0.), _clEnergy(energy),_clCentroid(centroid),_clWidth(width), _clNumStrips(numStrips),_clLastStrip(lastStrip),_clSeedStrip(seed), _clCentroidCM(0.),_clWidthCM(0.), _lineSlope(0.),_lineIntercept(0.),_lineInterceptErr(0.), _clusterZ(0.), _fiveOverNineRatio(fiveOverNineRatio), _chisq(chisq), _quality(quality),_qEnergy(qEnergy),version(-1) { PesGeometry pesGeometry(centroid, width); _clCentroidCM = pesGeometry.centroid(); _clWidthCM = pesGeometry.width(); } float PesCluster::pesProfileRatio5by9() const { return(_fiveOverNineRatio); } // Copy constructor : PesCluster::PesCluster(const PesCluster& oldPes) { _view = oldPes._view; _octant = oldPes._octant; _clEnergy = oldPes._clEnergy; _clCentroid = oldPes._clCentroid; _clWidth = oldPes._clWidth; _clNumStrips = oldPes._clNumStrips; _clLastStrip = oldPes._clLastStrip; _clSeedStrip = oldPes._clSeedStrip; _clCentroidCM = oldPes._clCentroidCM; _clWidthCM = oldPes._clWidthCM; _lineSlope = oldPes._lineSlope; _lineIntercept = oldPes._lineIntercept; _lineInterceptErr = oldPes._lineInterceptErr; _clusterZ = oldPes._clusterZ; _fiveOverNineRatio = oldPes._fiveOverNineRatio; _chisq = oldPes._chisq; _qEnergy = oldPes._qEnergy; _quality = oldPes._quality; version = oldPes.version; } //the next three methods were moved here from the .icc file to prevent a linker //error. bool PesCluster::etaRegion() const { return (seedStrip() < NUM_STRIPS_LOWETA ? 0 : 1);//boundary between high and low eta is 170. } void PesCluster::setClusterWidth(double clWidth){ _clWidth = clWidth; _clWidthCM = clWidth * STRIP_WIDTH; } void PesCluster::setCentroid(float centroid) { _clCentroid = centroid; _clCentroidCM = centroid * STRIP_WIDTH; } void PesCluster::print(std::ostream& os) const { os << " PesCluster : " << std::endl ; os << " PES code version = " << Version() << std::endl ; os << " view (0=U,1=V) = " << view() << std::endl; os << " octant = " << octant() << std::endl ; os << " number of strips = " << numStrips() << std::endl ; os << " last strip = " << lastStrip() << std::endl ; os << " mean position (in strips)= " << centroid() << std::endl ; os << " width (in strips) = " << clusterWidth() << std::endl ; //os << " mean position (in cm) = " << centroidCM() << std::endl ; //os << " width (in cm) = " << widthCM() << std::endl ; os << " line slope = " << lineSlope() << std::endl ; os << " line intercept = " << lineIntercept() << std::endl ; os << " line intercept error = " << lineInterceptErr() << std::endl ; os << " cluster z position = " << clusterZ() << std::endl; os << " cluster energy = " << energy()< PesCluster::strips(int num, bool print) const { // Make a vector full of dummy strips. It should have 2*num + 1 entries, // or as many entries as strips in the cluster if num is not set. int size = _clNumStrips; if (num > -1) size = (2*num)+1; if (print) std::cout << "********************" << "Number of strips returned: " << size << std::endl; PlugStrip dum; std::vector strips(size, dum); // Get the PlugStripColl PlugStripColl_ch pscch; if (PlugStripColl::find(pscch) != PlugStripColl::OK) { errlog(ELwarning, "Can't find PlugStripColl") << "@SUB=PesCluster::strips" << endmsg; return strips; } // Retrieve strips between seed-num and seed+num or between // last-size+1 and last. Put them in order. int high = _clLastStrip; int low = high - size + 1; if (num > -1) { high = _clSeedStrip + num; low = _clSeedStrip - num; } for (PlugStripColl::const_iterator it = pscch->contents().begin() ; it != pscch->contents().end() ; it++) { if (it->PesOctant() == _octant && it->PesPlug() == side() && it->PesLayer() == _view && it->PesStrip() >= low && it->PesStrip() <= high) { strips[it->PesStrip()-low] = *it; } } if (print) for (std::vector::iterator test = strips.begin() ; test != strips.end() ; test++) std::cout << *test << std::endl; return strips; } //Note: This method is obsolete since the global x,y, etc are calculated //first inside a chamber and then globally using x and y.... //bht 7 May 2001 void PesCluster::makeLine(int iphi, int layer, int i_ew) { _lineSlope = 0; _lineIntercept = 0; _lineInterceptErr = 0; } //=========================================================================== // Required by StreamableObject //=========================================================================== void PesCluster::Streamer(TBuffer& iobuffer) { //----------------------------------------------------------------------------- // Read object from buffer //----------------------------------------------------------------------------- if (iobuffer.IsReading()) { ShowerMaxCluster::Streamer(iobuffer); //Version_t version; iobuffer >> version; //std::cout << "Version is " << version << std::endl; if (version == 1) { iobuffer >> _view >> _octant >> _clEnergy >> _clCentroid >> _clWidth >> _clNumStrips >> _clLastStrip >> _clSeedStrip >> _clCentroidCM >> _clWidthCM >> _lineSlope >> _lineIntercept >> _lineInterceptErr >> _clusterZ ; } else if (version == 2) { iobuffer >> _view >> _octant >> _clEnergy >> _clCentroid >> _clWidth >> _clNumStrips >> _clLastStrip >> _clSeedStrip >> _clCentroidCM >> _clWidthCM >> _lineSlope >> _lineIntercept >> _lineInterceptErr >> _clusterZ >> _fiveOverNineRatio; } else if (version == 3) { iobuffer >> _view >> _octant >> _clEnergy >> _clCentroid >> _clWidth >> _clNumStrips >> _clLastStrip >> _clSeedStrip >> _clCentroidCM >> _clWidthCM >> _lineSlope >> _lineIntercept >> _lineInterceptErr >> _clusterZ >> _fiveOverNineRatio >> _quality >> _chisq ; } else { ERRLOG( ELerror, "Unsupported PesCluster version" ) << "@SUB=PesCluster::Streamer()" << "PesCluster cannot be read" << endmsg; } } //----------------------------------------------------------------------------- // Write object to buffer //----------------------------------------------------------------------------- else if (iobuffer.IsWriting()) { ShowerMaxCluster::Streamer(iobuffer); iobuffer << class_version(); iobuffer << _view << _octant << _clEnergy << _clCentroid << _clWidth << _clNumStrips << _clLastStrip << _clSeedStrip << _clCentroidCM << _clWidthCM << _lineSlope << _lineIntercept << _lineInterceptErr << _clusterZ << _fiveOverNineRatio << _quality << _chisq ; } //----------------------------------------------------------------------------- // Unanticipated action //----------------------------------------------------------------------------- else { ERRLOG( ELerror, "PesCluster::Streamer()") << "@SUB=PesCluster::Streamer" << "NOTHING DONE." << endmsg; } } bool PesCluster::postread(EventRecord* p) {return ShowerMaxCluster::postread(p);} bool PesCluster::prewrite(EventRecord* p) {return ShowerMaxCluster::prewrite(p);} /****************************************************************************** * ALL DONE * *****************************************************************************/