Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running code-format for reconstruction #27140

Merged
merged 2 commits into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 34 additions & 40 deletions DataFormats/SiStripCluster/interface/SiStripCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,36 @@
#include <numeric>
#include "FWCore/MessageLogger/interface/MessageLogger.h"

class SiStripCluster {
class SiStripCluster {
public:
typedef std::vector<SiStripDigi>::const_iterator SiStripDigiIter;
typedef std::pair<SiStripDigiIter, SiStripDigiIter> SiStripDigiRange;

typedef std::vector<SiStripDigi>::const_iterator SiStripDigiIter;
typedef std::pair<SiStripDigiIter,SiStripDigiIter> SiStripDigiRange;

static const uint16_t stripIndexMask = 0x7FFF; // The first strip index is in the low 15 bits of firstStrip_
static const uint16_t stripIndexMask = 0x7FFF; // The first strip index is in the low 15 bits of firstStrip_
static const uint16_t mergedValueMask = 0x8000; // The merged state is given by the high bit of firstStrip_


/** Construct from a range of digis that form a cluster and from
* a DetID. The range is assumed to be non-empty.
*/

SiStripCluster() {}

explicit SiStripCluster(const SiStripDigiRange& range);

template<typename Iter>
SiStripCluster(const uint16_t& firstStrip,
Iter begin, Iter end ):
amplitudes_(begin,end), firstStrip_(firstStrip) {}
template <typename Iter>
SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end) : amplitudes_(begin, end), firstStrip_(firstStrip) {}

template<typename Iter>
SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end, bool merged):
amplitudes_(begin,end), firstStrip_(firstStrip) {
if (merged) firstStrip_ |= mergedValueMask; // if this is a candidate merged cluster
}
template <typename Iter>
SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end, bool merged)
: amplitudes_(begin, end), firstStrip_(firstStrip) {
if (merged)
firstStrip_ |= mergedValueMask; // if this is a candidate merged cluster
}

/** The number of the first strip in the cluster.
* The high bit of firstStrip_ indicates whether the cluster is a candidate for being merged.
*/
uint16_t firstStrip() const {return firstStrip_ & stripIndexMask;}
uint16_t firstStrip() const { return firstStrip_ & stripIndexMask; }

/** The amplitudes of the strips forming the cluster.
* The amplitudes are on consecutive strips; if a strip is missing
Expand All @@ -51,7 +48,7 @@ class SiStripCluster {
* You can find the special meanings of values { 0, 254, 255} in section 3.4.1 of
* http://www.te.rl.ac.uk/esdg/cms-fed/firmware/Documents/FE_FPGA_Technical_Description.pdf
*/
const std::vector<uint8_t>& amplitudes() const {return amplitudes_;}
const std::vector<uint8_t>& amplitudes() const { return amplitudes_; }

/** The barycenter of the cluster, not corrected for Lorentz shift;
* should not be used as position estimate for tracking.
Expand All @@ -61,31 +58,29 @@ class SiStripCluster {
/** total charge
*
*/
int charge() const { return std::accumulate(amplitudes().begin(), amplitudes().end(), int(0)); }
int charge() const { return std::accumulate(amplitudes().begin(), amplitudes().end(), int(0)); }

/** Test (set) the merged status of the cluster
*
*/
bool isMerged() const {return (firstStrip_ & mergedValueMask) != 0;}
void setMerged(bool mergedState) {mergedState ? firstStrip_ |= mergedValueMask : firstStrip_ &= stripIndexMask;}

float getSplitClusterError () const { return error_x; }
void setSplitClusterError ( float errx ) { error_x = errx; }
bool isMerged() const { return (firstStrip_ & mergedValueMask) != 0; }
void setMerged(bool mergedState) { mergedState ? firstStrip_ |= mergedValueMask : firstStrip_ &= stripIndexMask; }

float getSplitClusterError() const { return error_x; }
void setSplitClusterError(float errx) { error_x = errx; }

private:
std::vector<uint8_t> amplitudes_;

std::vector<uint8_t> amplitudes_;

uint16_t firstStrip_ = 0;
uint16_t firstStrip_ = 0;

// ggiurgiu@fnal.gov, 01/05/12
// Add cluster errors to be used by rechits from split clusters.
// A rechit from a split cluster has larger errors than rechits from normal clusters.
// However, when presented with a cluster, the CPE does not know if the cluster comes
// from a splitting procedure or not. That's why we have to instruct the CPE to use
// Add cluster errors to be used by rechits from split clusters.
// A rechit from a split cluster has larger errors than rechits from normal clusters.
// However, when presented with a cluster, the CPE does not know if the cluster comes
// from a splitting procedure or not. That's why we have to instruct the CPE to use
// appropriate errors for split clusters.
// To avoid increase of data size on disk,these new data members are set as transient in:
// To avoid increase of data size on disk,these new data members are set as transient in:
// DataFormats/SiStripCluster/src/classes_def.xml
float error_x = -99999.9;

Expand All @@ -94,19 +89,18 @@ class SiStripCluster {
// The CPE will check these errors and if they are not un-physical,
// it will recognize the clusters as split and assign these (increased)
// errors to the corresponding rechit.

};

// Comparison operators
inline bool operator<( const SiStripCluster& one, const SiStripCluster& other) {
return one.firstStrip() < other.firstStrip();
}
inline bool operator<(const SiStripCluster& one, const SiStripCluster& other) {
return one.firstStrip() < other.firstStrip();
}

inline bool operator<(const SiStripCluster& cluster, const uint16_t& firstStrip) {
return cluster.firstStrip() < firstStrip;
}
}

inline bool operator<(const uint16_t& firstStrip,const SiStripCluster& cluster) {
inline bool operator<(const uint16_t& firstStrip, const SiStripCluster& cluster) {
return firstStrip < cluster.firstStrip();
}
#endif // DATAFORMATS_SISTRIPCLUSTER_H
}
#endif // DATAFORMATS_SISTRIPCLUSTER_H
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifndef DATAFORMATS_SISTRIPCLUSTERCOLLECTION_H
#define DATAFORMATS_SISTRIPCLUSTERCOLLECTION_H
#endif //


#endif //
66 changes: 31 additions & 35 deletions DataFormats/SiStripCluster/interface/SiStripClusterTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,52 @@
#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h"
#include "DataFormats/SiStripDetId/interface/SiStripDetId.h"

#include<numeric>
#include <numeric>

namespace siStripClusterTools {

// to be moved and optimized in TrackerCommon when TrackerTopology will support moduleGeometry
inline float sensorThicknessInverse (DetId detid)
{
if (detid.subdetId()>=SiStripDetId::TIB) {
SiStripDetId siStripDetId = detid();
if (siStripDetId.subdetId()==SiStripDetId::TOB) return 1.f/0.047f;
if (siStripDetId.moduleGeometry()==SiStripModuleGeometry::W5 || siStripDetId.moduleGeometry()==SiStripModuleGeometry::W6 ||
siStripDetId.moduleGeometry()==SiStripModuleGeometry::W7)
return 1.f/0.047f;
return 1.f/0.029f; // so it is TEC ring 1-4 or TIB or TOB;
} else if (detid.subdetId()==1) return 1.f/0.0285f;
else return 1.f/0.027f;
inline float sensorThicknessInverse(DetId detid) {
if (detid.subdetId() >= SiStripDetId::TIB) {
SiStripDetId siStripDetId = detid();
if (siStripDetId.subdetId() == SiStripDetId::TOB)
return 1.f / 0.047f;
if (siStripDetId.moduleGeometry() == SiStripModuleGeometry::W5 ||
siStripDetId.moduleGeometry() == SiStripModuleGeometry::W6 ||
siStripDetId.moduleGeometry() == SiStripModuleGeometry::W7)
return 1.f / 0.047f;
return 1.f / 0.029f; // so it is TEC ring 1-4 or TIB or TOB;
} else if (detid.subdetId() == 1)
return 1.f / 0.0285f;
else
return 1.f / 0.027f;
}


template<typename Iter>
template <typename Iter>
inline float chargePerCM(DetId detid, Iter a, Iter b) {
return float(std::accumulate(a,b,int(0)))*sensorThicknessInverse(detid);
return float(std::accumulate(a, b, int(0))) * sensorThicknessInverse(detid);
}

template<typename Clus>
inline float chargePerCM(DetId detid, Clus const & cl) {
return cl.charge()*sensorThicknessInverse(detid);
template <typename Clus>
inline float chargePerCM(DetId detid, Clus const& cl) {
return cl.charge() * sensorThicknessInverse(detid);
}


template<typename Clus>
inline float chargePerCM(DetId detid, Clus const & cl, LocalTrajectoryParameters const & tp) {
return chargePerCM(detid,cl)*tp.absdz();
template <typename Clus>
inline float chargePerCM(DetId detid, Clus const& cl, LocalTrajectoryParameters const& tp) {
return chargePerCM(detid, cl) * tp.absdz();
}

template<typename Clus>
inline float chargePerCM(Clus const & cl, LocalTrajectoryParameters const & tp, float invThick) {
return cl.charge()*invThick*tp.absdz();
template <typename Clus>
inline float chargePerCM(Clus const& cl, LocalTrajectoryParameters const& tp, float invThick) {
return cl.charge() * invThick * tp.absdz();
}


template<typename Clus>
inline float chargePerCM(DetId detid, Clus const & cl, const LocalVector & ldir) {
return chargePerCM(detid,cl)*std::abs(ldir.z())/ldir.mag();
template <typename Clus>
inline float chargePerCM(DetId detid, Clus const& cl, const LocalVector& ldir) {
return chargePerCM(detid, cl) * std::abs(ldir.z()) / ldir.mag();
}

} // namespace siStripClusterTools


}


#endif // DataFormatsSiStripClusterSiStripClusterTools_H

#endif // DataFormatsSiStripClusterSiStripClusterTools_H
30 changes: 12 additions & 18 deletions DataFormats/SiStripCluster/src/SiStripCluster.cc
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@

#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"

SiStripCluster::SiStripCluster(const SiStripDigiRange& range) :
firstStrip_(range.first->strip()),
error_x(-99999.9)
{
SiStripCluster::SiStripCluster(const SiStripDigiRange& range) : firstStrip_(range.first->strip()), error_x(-99999.9) {
amplitudes_.reserve(range.second - range.first);

amplitudes_.reserve( range.second - range.first);

uint16_t lastStrip=0;
uint16_t lastStrip = 0;
bool firstInloop = true;
for (SiStripDigiIter i=range.first; i!=range.second; i++) {

for (SiStripDigiIter i = range.first; i != range.second; i++) {
/// check if digis consecutive
if (!firstInloop && i->strip() != lastStrip + 1) {
for (int j=0; j < i->strip()-(lastStrip+1); j++) {
amplitudes_.push_back( 0);
for (int j = 0; j < i->strip() - (lastStrip + 1); j++) {
amplitudes_.push_back(0);
}
}
lastStrip = i->strip();
firstInloop = false;
amplitudes_.push_back(i->adc());

amplitudes_.push_back(i->adc());
}
}


float SiStripCluster::barycenter() const{
float SiStripCluster::barycenter() const {
int sumx = 0;
int suma = 0;
auto asize = amplitudes_.size();
for (auto i=0U;i<asize;++i) {
sumx += i*amplitudes_[i];
for (auto i = 0U; i < asize; ++i) {
sumx += i * amplitudes_[i];
suma += amplitudes_[i];
}

// strip centers are offcet by half pitch w.r.t. strip numbers,
// so one has to add 0.5 to get the correct barycenter position.
// Need to mask off the high bit of firstStrip_, which contains the merged status.
Expand Down
4 changes: 1 addition & 3 deletions DataFormats/SiStripCluster/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/Common/interface/ContainerMask.h"



#endif // SISTRIPCLUSTER_CLASSES_H
#endif // SISTRIPCLUSTER_CLASSES_H
Loading