20 EBRecHitCollectionToken_(iC.consumes<
EBRecHitCollection>(iConfig.getParameter<
edm::InputTag>(
"EBRecHitCollection"))),
21 EERecHitCollectionToken_(iC.consumes<
EERecHitCollection>(iConfig.getParameter<
edm::InputTag>(
"EERecHitCollection")))
60 for(reco::TrackCollection::const_iterator ndTrack = tracks->begin(); ndTrack != tracks->end(); ++ndTrack) {
71 std::map<int,GlobalPoint> trackExitPositionMap;
72 std::map<int,float> trackCrossedXtalCurvedMap;
76 std::vector<SteppingHelixStateInfo> neckLace;
79 double totalLengthCurved = 0.;
82 if(neckLace.size() > 1)
85 trackCrossedXtalCurvedMap,
95 float sumWeightedTime = 0;
96 float sumTimeErrorSqr = 0;
98 float sumTrackLength = 0;
99 std::vector<EcalRecHit> crossedRecHits;
102 std::map<int,GlobalPoint>::const_iterator trackExitMapIt = trackExitPositionMap.begin();
103 for(std::map<int,float>::const_iterator mapIt = trackCrossedXtalCurvedMap.begin();
104 mapIt != trackCrossedXtalCurvedMap.end(); ++mapIt)
109 thisHit = ebRecHits->
find(ebDetId);
110 if(thisHit == ebRecHits->
end())
124 sumTrackLength+=mapIt->second;
126 crossedRecHits.push_back(hit);
144 sumWeightedTime+=hit.
time()/(errorOnThis*errorOnThis);
145 sumTimeErrorSqr+=1/(errorOnThis*errorOnThis);
151 if(!crossedRecHits.empty())
154 sort(crossedRecHits.begin(),crossedRecHits.end(),
EcalRecHitLess());
157 result.
ecalDeDx = sumEnergy/sumTrackLength;
162 if(sumTimeErrorSqr > 0)
164 result.
ecalTime = sumWeightedTime/sumTimeErrorSqr;
166 DetId maxEnergyId = crossedRecHits.begin()->id();
168 if(maxEnergyId !=
DetId())
173 double frontFaceR =
sqrt(
pow(position.
x(),2)+
pow(position.
y(),2)+
pow(position.
z(),2));
174 double muonShowerMax = frontFaceR+11.5;
175 double gammaShowerMax = frontFaceR+6.23;
176 double speedOfLight = 29.979;
177 result.
ecalBeta = (muonShowerMax)/(result.
ecalTime*speedOfLight+gammaShowerMax);
217 prop -> setMaterialMode(
false);
218 prop -> applyRadX0Correction(
true);
224 std::map<int,float>& trackCrossedXtalMap,
225 double& totalLengthCurved,
230 const std::vector<SteppingHelixStateInfo>& neckLace)
233 internalPointCurved = origin ;
234 externalPointCurved = origin ;
236 bool firstPoint =
false;
237 trackCrossedXtalMap.clear();
242 for(std::vector<SteppingHelixStateInfo>::const_iterator itr = (neckLace.begin() + 1); itr != neckLace.end(); ++itr)
245 std::vector<DetId> surroundingMatrix;
247 EBDetId closestBarrelDetIdToProbe = ((theBarrelSubdetGeometry -> getClosestCell(probe_gp)).rawId());
248 EEDetId closestEndcapDetIdToProbe = ((theEndcapSubdetGeometry -> getClosestCell(probe_gp)).rawId());
251 if( (closestEndcapDetIdToProbe) &&
253 getGeometry(closestEndcapDetIdToProbe)->inside(probe_gp)) )
255 double step = ((*itr).position() - (*(itr-1)).position()).
mag();
257 addStepToXtal(trackExitPositionMap, trackCrossedXtalMap, closestEndcapDetIdToProbe, step, point, theEndcapSubdetGeometry);
258 totalLengthCurved +=
step;
260 if (firstPoint ==
false)
262 internalPointCurved = probe_gp ;
266 externalPointCurved = probe_gp ;
269 if( (closestBarrelDetIdToProbe) &&
271 getGeometry(closestBarrelDetIdToProbe)->inside(probe_gp)) )
273 double step = ((*itr).position() - (*(itr-1)).position()).
mag();
275 addStepToXtal(trackExitPositionMap, trackCrossedXtalMap, closestBarrelDetIdToProbe, step, point, theBarrelSubdetGeometry);
276 totalLengthCurved +=
step;
278 if (firstPoint ==
false)
280 internalPointCurved = probe_gp ;
284 externalPointCurved = probe_gp ;
291 for(
unsigned int k=0;
k<surroundingMatrix.size(); ++
k ) {
294 double step = ((*itr).position() - (*(itr-1)).position()).
mag();
296 addStepToXtal(trackExitPositionMap, trackCrossedXtalMap, surroundingMatrix[
k], step,
298 totalLengthCurved +=
step;
300 if (firstPoint ==
false)
302 internalPointCurved = probe_gp ;
306 externalPointCurved = probe_gp ;
311 surroundingMatrix.clear();
319 std::map<int,float>& trackCrossedXtalMap,
326 auto cell_p = theSubdetGeometry->
getGeometry(aDetId);
330 std::map<int,GlobalPoint>::iterator xtal = trackExitPositionMap.find(aDetId.
rawId());
331 if (xtal!=trackExitPositionMap.end())
332 ((*xtal).second)=
diff;
334 trackExitPositionMap.insert(std::pair<int,GlobalPoint>(aDetId.
rawId(),
diff));
336 std::map<int,float>::iterator xtal2 = trackCrossedXtalMap.find(aDetId.
rawId());
337 if (xtal2!= trackCrossedXtalMap.end())
338 ((*xtal2).second)+=
step;
340 trackCrossedXtalMap.insert(std::pair<int,float>(aDetId.
rawId(),
step));
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
GlobalPoint getPosition(const DetId &)
int getDetailedTrackLengthInXtals(std::map< int, GlobalPoint > &trackExitPositionMap, std::map< int, float > &trackCrossedXtalMap, double &totalLengthCurved, GlobalPoint &internalPointCurved, GlobalPoint &externalPointCurved, const CaloGeometry *theGeometry, const CaloTopology *theTopology, const std::vector< SteppingHelixStateInfo > &neckLace)
std::vector< float > ecalTrackLengths
std::vector< float > ecalEnergies
bool isTimeErrorValid() const
std::vector< const HBHERecHit * > crossedHcalRecHits
bool getByToken(EDGetToken token, Handle< PROD > &result) const
BetaCalculatorECAL(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
double maxZ(bool withTolerance=true) const
std::vector< GlobalPoint > ecalTrackExitPositions
void useDefaultPropagator()
use the default propagator
std::vector< EcalRecHit >::const_iterator const_iterator
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
void addInfoToCandidate(susybsm::HSCParticle &candidate, edm::Handle< reco::TrackCollection > &tracks, edm::Event &iEvent, const edm::EventSetup &iSetup, susybsm::HSCPCaloInfo &caloInfo)
double minZ(bool withTolerance=true) const
CaloGeometry const * getGeometry()
double nXnEnergy(const DetId &, EnergyType, int gridSize=1)
get energy of the NxN shape (N = 2*gridSize + 1) around given detector element
std::vector< DetId > ecalDetIds
std::vector< float > ecalTimeErrors
uint32_t rawId() const
get the raw id
std::vector< float > ecalTimes
edm::EDGetTokenT< EERecHitCollection > EERecHitCollectionToken_
edm::ESHandle< DetIdAssociator > ecalDetIdAssociator_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
std::vector< float > ecalChi2s
double minR(bool withTolerance=true) const
const_iterator end() const
TrackAssociatorParameters parameters_
double outerEta() const
pseudorapidity of the momentum vector at the outermost hit position
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Flags recoFlag() const
DEPRECATED provided for temporary backward compatibility.
void addStepToXtal(std::map< int, GlobalPoint > &trackExitPositionMap, std::map< int, float > &trackCrossedXtalMap, DetId aDetId, float step, GlobalPoint point, const CaloSubdetectorGeometry *theSubdetGeometry)
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
reco::TrackRef trackRef() const
TrackDetectorAssociator trackAssociator_
iterator find(key_type k)
static int position[264][3]
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
std::vector< float > ecalOutOfTimeChi2s
const FiducialVolume & volume() const
get active detector volume
std::vector< SteppingHelixStateInfo > propagateThoughFromIP(const SteppingHelixStateInfo &state, const Propagator *prop, const FiducialVolume &volume, int nsteps, float step, float minR, float minZ, float maxR, float maxZ)
edm::EDGetTokenT< EBRecHitCollection > EBRecHitCollectionToken_
edm::ESHandle< MagneticField > bField_
std::vector< float > ecalOutOfTimeEnergies
T const * product() const
double outerPhi() const
azimuthal angle of the momentum vector at the outermost hit position
edm::ESHandle< CaloGeometry > theCaloGeometry_
double maxR(bool withTolerance=true) const
Power< A, B >::type pow(const A &a, const B &b)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
std::vector< SteppingHelixStateInfo > calcEcalDeposit(const FreeTrajectoryState *tkInnerState, const DetIdAssociator &associator)