17 using namespace susybsm;
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.size() > 0)
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());
252 getGeometry(closestEndcapDetIdToProbe)->inside(probe_gp)) )
254 double step = ((*itr).position() - (*(itr-1)).position()).
mag();
256 addStepToXtal(trackExitPositionMap, trackCrossedXtalMap, closestEndcapDetIdToProbe, step, point, theEndcapSubdetGeometry);
257 totalLengthCurved +=
step;
259 if (firstPoint ==
false)
261 internalPointCurved = probe_gp ;
265 externalPointCurved = probe_gp ;
269 getGeometry(closestBarrelDetIdToProbe)->inside(probe_gp)) )
271 double step = ((*itr).position() - (*(itr-1)).position()).
mag();
273 addStepToXtal(trackExitPositionMap, trackCrossedXtalMap, closestBarrelDetIdToProbe, step, point, theBarrelSubdetGeometry);
274 totalLengthCurved +=
step;
276 if (firstPoint ==
false)
278 internalPointCurved = probe_gp ;
282 externalPointCurved = probe_gp ;
289 for(
unsigned int k=0;
k<surroundingMatrix.size(); ++
k ) {
292 double step = ((*itr).position() - (*(itr-1)).position()).
mag();
294 addStepToXtal(trackExitPositionMap, trackCrossedXtalMap, surroundingMatrix[
k], step,
296 totalLengthCurved +=
step;
298 if (firstPoint ==
false)
300 internalPointCurved = probe_gp ;
304 externalPointCurved = probe_gp ;
309 surroundingMatrix.clear();
317 std::map<int,float>& trackCrossedXtalMap,
328 std::map<int,GlobalPoint>::iterator xtal = trackExitPositionMap.find(aDetId.
rawId());
329 if (xtal!=trackExitPositionMap.end())
330 ((*xtal).second)=
diff;
332 trackExitPositionMap.insert(std::pair<int,GlobalPoint>(aDetId.
rawId(),
diff));
334 std::map<int,float>::iterator xtal2 = trackCrossedXtalMap.find(aDetId.
rawId());
335 if (xtal2!= trackCrossedXtalMap.end())
336 ((*xtal2).second)+=
step;
338 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
static int position[TOTALCHAMBERS][3]
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< DetId > ecalDetIds
std::vector< float > ecalTimeErrors
uint32_t rawId() const
get the raw id
std::vector< float > ecalTimes
edm::EDGetTokenT< EERecHitCollection > EERecHitCollectionToken_
tuple SteppingHelixPropagator
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
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
Flags recoFlag() const
DEPRECATED provided for temporary backward compatibility.
T const * product() const
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
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
reco::TrackRef trackRef() const
TrackDetectorAssociator trackAssociator_
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
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)