CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

pftools::CaloWindow Class Reference

#include <CaloWindow.h>

List of all members.

Public Member Functions

bool addHit (double eta, double phi, double energy)
 CaloWindow ()
 CaloWindow (double eta, double phi, unsigned nRings, double deltaR, unsigned nPanes, double axis=0.0)
std::map< unsigned, CaloRinggetRingDepositions () const
std::map< unsigned, double > getRingEnergySummations () const
void init (double eta, double phi, unsigned nRings, double deltaR, unsigned nPanes, double axis=0.0)
void printEnergies (std::ostream &s, double range=1.0)
void reset ()
std::vector< double > stream (double normalisation=1.0) const
virtual ~CaloWindow ()

Private Member Functions

std::pair< unsigned, unsigned > relativePosition (double eta, double phi) const

Private Attributes

double axis_
double baryEta_
double baryPhi_
double deltaR_
std::map< unsigned, CaloRingenergies_
unsigned nPanes_
unsigned nRings_

Friends

std::ostream & operator<< (std::ostream &s, const CaloWindow &caloWindow)

Detailed Description

Definition at line 94 of file CaloWindow.h.


Constructor & Destructor Documentation

CaloWindow::CaloWindow ( )

Definition at line 124 of file CaloWindow.cc.

                       :
        baryEta_(0.0), baryPhi_(0.0), nRings_(1), deltaR_(0.1), nPanes_(1),  axis_(0.0) {

}
CaloWindow::CaloWindow ( double  eta,
double  phi,
unsigned  nRings,
double  deltaR,
unsigned  nPanes,
double  axis = 0.0 
)

Create a circular calo window centred on eta, phi, with nRings of size deltaR.

Definition at line 129 of file CaloWindow.cc.

References init().

                                                                                                           {

        init(eta, phi, nRings, deltaR, nPanes, axis);
}
CaloWindow::~CaloWindow ( ) [virtual]

Definition at line 156 of file CaloWindow.cc.

                        {

}

Member Function Documentation

bool CaloWindow::addHit ( double  eta,
double  phi,
double  energy 
)

Adds a hit contribution. If eta, phi are outside the window, this method returns false and does not add the energy to the window.

If ok, it returns true.

Definition at line 226 of file CaloWindow.cc.

References pftools::CaloRing::addEnergy(), trackerHits::c, energies_, nRings_, position, and relativePosition().

Referenced by pftools::TestCaloWindow::doTest(), and pftools::Calibratable::fillCaloWindow().

                                                             {

        std::pair<unsigned, unsigned> position = relativePosition(eta, phi);
        if (position.first >= nRings_) {
/*              double dEta = eta - baryEta_;
                double dPhi = deltaPhi(phi, baryPhi_);
                double dR = deltaR(eta, phi, baryEta_, baryPhi_);
                LogDebug("CaloWindow")
                                << "Hit is outside my range - it would be in ring "
                                << position.first << ", with dR = " << dR << std::endl;*/
                return false;
        }
//      std::cout << "Adding hit to ring " << position.first << " in position "
//                      << position.second << " with energy " << energy << "\n";

        CaloRing& c = energies_[position.first];
        c.addEnergy(position.second, energy);

        return true;
}
std::map<unsigned, CaloRing> pftools::CaloWindow::getRingDepositions ( ) const [inline]

Return a vector of vectors: Each inner vector corresponds to a ring of window panes around the barycentre and the first entry of the bary centre itself

Definition at line 122 of file CaloWindow.h.

References energies_.

                                                              {
                return energies_;
        }
std::map< unsigned, double > CaloWindow::getRingEnergySummations ( ) const

Definition at line 246 of file CaloWindow.cc.

References submit::answer, and energies_.

                                                                   {
        std::map<unsigned, double> answer;
        for (std::map<unsigned, CaloRing>::const_iterator cit = energies_.begin(); cit
                        != energies_.end(); ++cit) {
                std::pair<unsigned, CaloRing> pair = *cit;
                answer[pair.first] = pair.second.totalE();
        }

        return answer;
}
void CaloWindow::init ( double  eta,
double  phi,
unsigned  nRings,
double  deltaR,
unsigned  nPanes,
double  axis = 0.0 
)

Definition at line 138 of file CaloWindow.cc.

References axis_, baryEta_, baryPhi_, trackerHits::c, deltaR(), deltaR_, energies_, eta(), j, nPanes_, nRings_, phi, and csvReporter::r.

Referenced by CaloWindow().

                                                                                                          {
        baryEta_ = eta;
        baryPhi_ = phi;
        nRings_ = nRings;
        deltaR_ = deltaR;
        nPanes_ = nPanes;
        axis_ = axis;

        energies_.clear();
        CaloRing c(1);
        energies_[0] = c;
        for (unsigned j(1); j < nRings_; ++j) {

                CaloRing r(nPanes);
                energies_[j] = r;
        }
}
void CaloWindow::printEnergies ( std::ostream &  s,
double  range = 1.0 
)

Definition at line 113 of file CaloWindow.cc.

References trackerHits::c, energies_, and pftools::CaloRing::printEnergies().

                                                          {

        for (std::map<unsigned, pftools::CaloRing>::const_iterator cit =
                        energies_.begin(); cit != energies_.end(); ++cit) {
                CaloRing c = (*cit).second;
                c.printEnergies(s, range);
                s << "\t";
        }

}
std::pair< unsigned, unsigned > CaloWindow::relativePosition ( double  eta,
double  phi 
) const [private]

Definition at line 160 of file CaloWindow.cc.

References axis_, baryEta_, baryPhi_, Geom::deltaPhi(), deltaR(), deltaR_, dPhi(), energies_, nRings_, Pi, relativeConstraints::ring, and edm::second().

Referenced by addHit().

                                  {
        //How far is this hit from the barycentre in deltaR?
        double dEta = eta - baryEta_;
        double dPhi = deltaPhi(phi, baryPhi_);

        double dR = deltaR(eta, phi, baryEta_, baryPhi_);

        unsigned ring = static_cast<unsigned> (floor(dR / deltaR_));

        if (ring == 0) {
                //LogDebug("CaloWindow") << "Relative position: adding to central ring\n";
                return std::pair<unsigned, unsigned>(0, 0);
        }

        if (ring >= nRings_) {
                return std::pair<unsigned, unsigned>(ring, 0);
        }

        double dTheta = 0;

        if (dEta > 0) {
                if (dPhi > 0)
                        dTheta = TMath::ATan(dPhi / dEta);
                else
                        dTheta = 2 * TMath::Pi() + TMath::ATan(dPhi / dEta);
        } else {
                if (dPhi > 0)
                        dTheta = TMath::Pi() + TMath::ATan(dPhi / dEta);
                else
                        dTheta = TMath::Pi() + TMath::ATan(dPhi / dEta);
        }
        //Rotation. Rotate theta into axis of caloWindow
        // and also by half a window pane.
        //TODO: bug check!!
        //double dThetaOrig(dTheta);
        double paneOn2 = TMath::Pi() / (*energies_.find(ring)).second.getNPanes();
        dTheta =  dTheta - axis_ - paneOn2;
        //Original theta between 0 and 2 Pi, but transform above might move us beyond this, so...
        //double dThetaCopy(dTheta);
        //std::cout << "dTheta " << dThetaOrig << ", axis " << axis_ << ", paneOn2 " << paneOn2 << ", thetaPrime " << dTheta << "\n";
        if(dTheta > 2 *TMath::Pi()) {
                //std::cout << "To infinity and beyond...\n";
                while(dTheta > 2 * TMath::Pi()) {
                        dTheta -= 2 * TMath::Pi();
                        //std::cout << "dTheta1 " << dTheta << "\n";
                }
        }
        else if (dTheta < 0) {
                //std::cout << "To infinity and beyond 2... dTheta = " << dTheta << "\n";
                while(dTheta < 0) {
                        dTheta += 2 * TMath::Pi();
                        //std::cout << "dTheta2 " << dTheta << "\n";
                }
        }

//      std::cout << "\tdTheta is " << dTheta << " rad \n";
        unsigned division = static_cast<unsigned> (floor((*energies_.find(ring)).second.getNPanes() * dTheta
                        / (TMath::Pi() * 2)));
        //LogDebug("CaloWindow") << "Ring is " << ring << ", pane is "
        //              << division << "\n";

        return std::pair<unsigned, unsigned>(ring, division);

}
void CaloWindow::reset ( void  )
vector< double > CaloWindow::stream ( double  normalisation = 1.0) const

Collapses all energies in all CaloRings into one vector of doubles

Parameters:
normalisation- divide each energy by this value
Returns:
a vector of doubles

Definition at line 95 of file CaloWindow.cc.

References trackerHits::c, energies_, pftools::CaloRing::getEnergies(), and i.

                                                            {
        vector<double> stream;
        for (map<unsigned, pftools::CaloRing>::const_iterator cit =
                        energies_.begin(); cit != energies_.end(); ++cit) {
                CaloRing c = (*cit).second;
                std::vector<double> ringE = c.getEnergies();
                stream.insert(stream.end(), ringE.begin(), ringE.end());
        }
        if(normalisation != 1.0){
                for(vector<double>::iterator i = stream.begin(); i != stream.end(); ++i) {
                        double& entry = *i;
                        entry /= normalisation;
                }
        }
        return stream;

}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const CaloWindow caloWindow 
) [friend]

Member Data Documentation

double pftools::CaloWindow::axis_ [private]

Definition at line 154 of file CaloWindow.h.

Referenced by init(), and relativePosition().

Definition at line 144 of file CaloWindow.h.

Referenced by init(), and relativePosition().

Definition at line 145 of file CaloWindow.h.

Referenced by init(), and relativePosition().

double pftools::CaloWindow::deltaR_ [private]

Definition at line 149 of file CaloWindow.h.

Referenced by init(), and relativePosition().

std::map<unsigned, CaloRing> pftools::CaloWindow::energies_ [private]
unsigned pftools::CaloWindow::nPanes_ [private]

Definition at line 151 of file CaloWindow.h.

Referenced by init().

unsigned pftools::CaloWindow::nRings_ [private]

Definition at line 147 of file CaloWindow.h.

Referenced by addHit(), init(), and relativePosition().