25 vector<CSCCathodeLayerInfo> clctInfo = lctDigis(clct, clctId, compdc);
29 throw cms::Exception(
"CSCCathodeLCTAnalyzer") <<
"+++ Number of CSCCathodeLayerInfo objects, " << clctInfo.size()
41 vector<CSCCathodeLayerInfo>::iterator pcli;
42 for (pcli = clctInfo.begin(); pcli != clctInfo.end(); pcli++) {
43 digiSimHitAssociator(*pcli, allSimHits);
61 vector<CSCCathodeLayerInfo> vectInfo;
67 int clct_bx = clct.
getBX();
70 if (clct_stripType == 0)
74 char stype = (clct_stripType == 0) ?
'D' :
'H';
75 LogDebug(
"lctDigis") <<
"\nlctDigis: CLCT keystrip = " << clct_keystrip <<
" (" << stype <<
")" 76 <<
" pattern = " << clct_pattern <<
"; Id:" 77 <<
" endcap " << clctId.
endcap() <<
", station " << clctId.
station() <<
", ring " 78 << clctId.
ring() <<
", chamber " << clctId.
chamber();
82 const int key_layer = 3;
84 const CSCLayer* csclayer = geom_->layer(layerId);
85 int key_stagger = (csclayer->geometry()->stagger() + 1) / 2;
92 vector<CSCComparatorDigi> digiMap;
95 hfstripDigis[i_hstrip] = -999;
100 digiNum[i_strip] = -999;
109 digi_num += preselectDigis(clct_bx, layerId, compdc, digiMap, hfstripDigis, time, comp, digiNum);
118 digi_num += preselectDigis(clct_bx, layerId_me1a, compdc, digiMap, hfstripDigis, time, comp, digiNum);
123 int max_pattern_strips, layer,
strip;
125 for (
int i_strip = 0; i_strip < max_pattern_strips; i_strip++) {
127 if (layer == i_layer) {
129 if (strip >= 0 && strip < CSCConstants::NUM_HALF_STRIPS) {
130 digiId = hfstripDigis[
strip];
135 tempInfo.
setId(layerId);
138 LogTrace(
"lctDigis") <<
" Digi on CLCT: strip/comp/time " << digiMap[digiId];
146 vectInfo.push_back(tempInfo);
155 vector<CSCComparatorDigi>& digiMap,
158 int comp[CSCConstants::MAX_NUM_STRIPS],
159 int digiNum[CSCConstants::MAX_NUM_STRIPS]) {
165 const int fifo_tbins = 12;
166 const int hit_persist = 4;
167 const int drift_delay = 2;
170 const CSCLayer* csclayer = geom_->layer(layerId);
173 bool me1a = (layerId.
station() == 1) && (layerId.
ring() == 4);
178 LogDebug(
"lctDigis") <<
"Comparator digi: layer " << layerId.
layer() - 1
179 <<
" strip/comparator/time =" << (*digiIt);
181 if ((*digiIt).getComparator() == 0 || (*digiIt).getComparator() == 1) {
182 int bx_time = (*digiIt).getTimeBin();
183 if (bx_time >= 0 && bx_time < fifo_tbins) {
185 int latch_bx = clct_bx + drift_delay;
186 if (bx_time <= latch_bx - hit_persist || bx_time > latch_bx) {
188 LogDebug(
"lctDigis") <<
"Late comparator digi: layer " << layerId.
layer() - 1
189 <<
" strip/comparator/time =" << (*digiIt) <<
" skipping...";
195 int i_strip = (*digiIt).getStrip() - 1;
196 if (me1a && i_strip < 16) {
202 if (
time[i_strip] <= 0 ||
time[i_strip] > bx_time) {
204 int i_hfstrip = 2 * i_strip + (*digiIt).getComparator() + stagger;
205 hfstripDigis[i_hfstrip] = digi_num;
208 comp[i_strip] = (*digiIt).getComparator();
209 time[i_strip] = bx_time;
210 digiNum[i_strip] = digi_num;
213 LogDebug(
"lctDigis") <<
"digi_num = " << digi_num <<
" half-strip = " << i_hfstrip
214 <<
" strip = " << i_strip;
218 digiMap.push_back(*digiIt);
232 vector<CSCComparatorDigi> thisLayerDigis = info.
getRecDigis();
233 if (!thisLayerDigis.empty()) {
235 bool me11 = (layerId.
station() == 1) && (layerId.
ring() == 1);
238 for (edm::PSimHitContainer::const_iterator simHitIt = allSimHits->begin(); simHitIt != allSimHits->end();
242 if (hitId == layerId)
243 simHits.push_back(*simHitIt);
246 if (hitId == layerId_me1a)
247 simHits.push_back(*simHitIt);
251 if (!simHits.empty()) {
252 ostringstream strstrm;
254 strstrm <<
"\nLayer " << layerId.
layer() <<
" has " << simHits.size() <<
" SimHit(s); phi value(s) = ";
258 for (vector<CSCComparatorDigi>::iterator
prd = thisLayerDigis.begin();
prd != thisLayerDigis.end();
prd++) {
259 double deltaPhiMin = 999.;
260 double bestHitPhi = 999.;
264 double digiPhi = getStripPhi(layerId, strip - 0.5);
266 const CSCLayer* csclayer = geom_->layer(layerId);
267 for (vector<PSimHit>::iterator psh = simHits.begin(); psh != simHits.end(); psh++) {
271 double hitPhi = hitGP.
phi();
273 strstrm << hitPhi <<
" ";
278 if (fabs(hitPhi - digiPhi) <
M_PI) {
279 deltaPhi = fabs(hitPhi - digiPhi);
282 LogDebug(
"digiSimHitAssociator") <<
"SimHit and Digi are close to edge!!!";
283 deltaPhi = fabs(fabs(hitPhi - digiPhi) - 2. *
M_PI);
285 if (deltaPhi < deltaPhiMin) {
292 strstrm <<
"\nDigi Phi: " << digiPhi <<
", closest SimHit phi: " << bestHitPhi
298 LogTrace(
"digiSimHitAssociator") << strstrm.str();
306 double& closestEta) {
312 int nearestHS = -999;
314 bool hit_found =
false;
318 vector<CSCCathodeLayerInfo>::const_iterator pli;
319 for (pli = allLayerInfo.begin(); pli != allLayerInfo.end(); pli++) {
320 if (pli->getId().layer() == key_layer) {
321 vector<PSimHit> thisLayerHits = pli->getSimHits();
322 if (!thisLayerHits.empty()) {
325 if (thisLayerHits.size() != 1) {
327 <<
"+++ Warning: " << thisLayerHits.size() <<
" SimHits in key layer " << key_layer <<
"! +++ \n";
328 for (
unsigned i = 0;
i < thisLayerHits.size();
i++) {
329 edm::LogWarning(
"L1CSCTPEmulatorWrongValues") <<
" SimHit # " <<
i << thisLayerHits[
i] <<
"\n";
332 matchedHit = thisLayerHits[0];
333 layerId = pli->getId();
340 if (hit_found ==
false) {
341 for (pli = allLayerInfo.begin(); pli != allLayerInfo.end(); pli++) {
343 if (!(pli->getRecDigis()).
empty() && !(pli->getSimHits()).
empty()) {
345 matchedHit = (pli->getSimHits())[0];
346 layerId = pli->getId();
355 const CSCLayer* csclayer = geom_->layer(layerId);
368 int nearestStrip =
static_cast<int>(
strip);
372 <<
") interval; strip = " << strip <<
" +++\n";
375 int comp = ((strip - nearestStrip) < 0.5) ? 0 : 1;
376 nearestHS = 2 * nearestStrip +
comp;
379 closestPhi = thisPoint.
phi();
380 closestEta = thisPoint.
eta();
381 ostringstream strstrm;
383 strstrm <<
"Matched cathode phi: " << closestPhi;
384 if (closestPhi < 0.) {
385 closestPhi += 2. *
M_PI;
387 strstrm <<
"(" << closestPhi <<
")";
390 strstrm <<
" eta: " << closestEta <<
" on a layer " << layerId.
layer() <<
" (1-6);" 391 <<
" nearest strip: " << nearestStrip;
392 LogDebug(
"nearestHS") << strstrm.str();
408 const CSCLayer* csclayer = geom_->layer(layerId);
418 double phi = digiGP.
phi();
std::vector< TYPE > getRecDigis() const
void digiSimHitAssociator(CSCCathodeLayerInfo &info, const edm::PSimHitContainer *allSimHits)
float strip(const LocalPoint &) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
void addComponent(const TYPE digi)
void setGeometry(const CSCGeometry *geom)
int preselectDigis(const int clct_bx, const CSCDetId &layerId, const CSCComparatorDigiCollection *compdc, std::vector< CSCComparatorDigi > &digiMap, int hfstripDigis[CSCConstants::NUM_HALF_STRIPS], int time[CSCConstants::MAX_NUM_STRIPS], int comp[CSCConstants::MAX_NUM_STRIPS], int digiNum[CSCConstants::MAX_NUM_STRIPS])
int getStripType() const
return striptype
std::vector< CSCCathodeLayerInfo > lctDigis(const CSCCLCTDigi &clct, const CSCDetId &clctId, const CSCComparatorDigiCollection *compdc)
static const int clct_pattern_offset[CSCConstants::MAX_HALFSTRIPS_IN_PATTERN]
Local3DPoint localPosition() const
int getBX() const
return BX
int nearestHS(const std::vector< CSCCathodeLayerInfo > &allLayerInfo, double &closestPhi, double &closestEta)
const CSCStripTopology * topology() const
void setId(const CSCDetId id)
int getPattern() const
return pattern
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
double getStripPhi(const CSCDetId &layerId, const float strip)
std::vector< CSCCathodeLayerInfo > getSimInfo(const CSCCLCTDigi &clct, const CSCDetId &clctId, const CSCComparatorDigiCollection *compdc, const edm::PSimHitContainer *allSimHits)
LocalPoint localPosition(float strip) const override
std::vector< PSimHit > PSimHitContainer
const CSCLayerGeometry * geometry() const
static const int clct_pattern[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]