38 vector<CSCCathodeLayerInfo> clctInfo = lctDigis(clct, clctId, compdc);
43 <<
"+++ Number of CSCCathodeLayerInfo objects, " << clctInfo.size()
55 vector<CSCCathodeLayerInfo>::iterator pcli;
56 for (pcli = clctInfo.begin(); pcli != clctInfo.end(); pcli++) {
57 digiSimHitAssociator(*pcli, allSimHits);
75 vector<CSCCathodeLayerInfo> vectInfo;
81 int clct_bx = clct.
getBX();
84 if (clct_stripType == 0) clct_keystrip /= 4;
87 char stype = (clct_stripType == 0) ?
'D' :
'H';
89 <<
"\nlctDigis: CLCT keystrip = " << clct_keystrip
90 <<
" (" << stype <<
")" <<
" pattern = " << clct_pattern <<
"; Id:" 91 <<
" endcap " << clctId.
endcap() <<
", station " << clctId.
station()
92 <<
", ring " << clctId.
ring() <<
", chamber " << clctId.
chamber();
96 const int key_layer = 3;
99 const CSCLayer* csclayer = geom_->layer(layerId);
100 int key_stagger = (csclayer->geometry()->stagger()+1)/2;
107 vector<CSCComparatorDigi> digiMap;
111 hfstripDigis[i_hstrip] = -999;
114 time[i_strip] = -999;
116 digiNum[i_strip] = -999;
126 digi_num += preselectDigis(clct_bx, layerId, compdc, digiMap,
128 time, comp, digiNum);
138 digi_num += preselectDigis(clct_bx, layerId_me1a, compdc, digiMap,
140 time, comp, digiNum);
145 int max_pattern_strips, layer,
strip;
147 for (
int i_strip = 0; i_strip < max_pattern_strips; i_strip++) {
149 if (layer == i_layer) {
150 strip = clct_keystrip + key_stagger +
152 if (strip >= 0 && strip < CSCConstants::NUM_HALF_STRIPS) {
153 digiId = hfstripDigis[
strip];
158 tempInfo.
setId(layerId);
161 <<
" Digi on CLCT: strip/comp/time " << digiMap[digiId];
169 vectInfo.push_back(tempInfo);
178 vector<CSCComparatorDigi>& digiMap,
181 int comp[CSCConstants::MAX_NUM_STRIPS],
182 int digiNum[CSCConstants::MAX_NUM_STRIPS]) {
188 const int fifo_tbins = 12;
189 const int hit_persist = 4;
190 const int drift_delay = 2;
193 const CSCLayer* csclayer = geom_->layer(layerId);
196 bool me1a = (layerId.
station() == 1) && (layerId.
ring() == 4);
200 digiIt != rcompd.second; ++digiIt) {
202 <<
"Comparator digi: layer " << layerId.
layer()-1
203 <<
" strip/comparator/time =" << (*digiIt);
205 if ((*digiIt).getComparator() == 0 || (*digiIt).getComparator() == 1) {
206 int bx_time = (*digiIt).getTimeBin();
207 if (bx_time >= 0 && bx_time < fifo_tbins) {
210 int latch_bx = clct_bx + drift_delay;
211 if (bx_time <= latch_bx-hit_persist || bx_time > latch_bx) {
213 <<
"Late comparator digi: layer " << layerId.
layer()-1
214 <<
" strip/comparator/time =" << (*digiIt) <<
" skipping...";
220 int i_strip = (*digiIt).getStrip() - 1;
221 if (me1a && i_strip < 16) {
227 if (
time[i_strip] <= 0 ||
time[i_strip] > bx_time) {
230 int i_hfstrip = 2*i_strip + (*digiIt).getComparator() + stagger;
231 hfstripDigis[i_hfstrip] = digi_num;
234 comp[i_strip] = (*digiIt).getComparator();
235 time[i_strip] = bx_time;
236 digiNum[i_strip] = digi_num;
239 <<
"digi_num = " << digi_num <<
" half-strip = " << i_hfstrip
240 <<
" strip = " << i_strip;
244 digiMap.push_back(*digiIt);
259 vector<CSCComparatorDigi> thisLayerDigis = info.
getRecDigis();
260 if (!thisLayerDigis.empty()) {
262 bool me11 = (layerId.
station() == 1) && (layerId.
ring() == 1);
265 for (edm::PSimHitContainer::const_iterator simHitIt = allSimHits->begin();
266 simHitIt != allSimHits->end(); simHitIt++) {
270 if (hitId == layerId)
271 simHits.push_back(*simHitIt);
275 if (hitId == layerId_me1a)
276 simHits.push_back(*simHitIt);
280 if (!simHits.empty()) {
281 ostringstream strstrm;
283 strstrm <<
"\nLayer " << layerId.
layer()
284 <<
" has " << simHits.size() <<
" SimHit(s); phi value(s) = ";
288 for (vector<CSCComparatorDigi>::iterator prd = thisLayerDigis.begin();
289 prd != thisLayerDigis.end(); prd++) {
290 double deltaPhiMin = 999.;
291 double bestHitPhi = 999.;
294 int strip = prd->getStrip();
295 double digiPhi = getStripPhi(layerId, strip-0.5);
297 const CSCLayer* csclayer = geom_->layer(layerId);
298 for (vector <PSimHit>::iterator psh = simHits.begin();
299 psh != simHits.end(); psh++) {
303 double hitPhi = hitGP.
phi();
305 strstrm << hitPhi <<
" ";
310 if (fabs(hitPhi - digiPhi) <
M_PI) {
311 deltaPhi = fabs(hitPhi - digiPhi);
315 <<
"SimHit and Digi are close to edge!!!";
316 deltaPhi = fabs(fabs(hitPhi - digiPhi) - 2.*
M_PI);
318 if (deltaPhi < deltaPhiMin) {
325 strstrm <<
"\nDigi Phi: " << digiPhi
326 <<
", closest SimHit phi: " << bestHitPhi
332 LogTrace(
"digiSimHitAssociator") << strstrm.str();
339 const vector<CSCCathodeLayerInfo>& allLayerInfo,
340 double& closestPhi,
double& closestEta) {
346 int nearestHS = -999;
348 bool hit_found =
false;
352 vector<CSCCathodeLayerInfo>::const_iterator pli;
353 for (pli = allLayerInfo.begin(); pli != allLayerInfo.end(); pli++) {
354 if (pli->getId().layer() == key_layer) {
355 vector<PSimHit> thisLayerHits = pli->getSimHits();
356 if (thisLayerHits.size() > 0) {
359 if (thisLayerHits.size() != 1) {
361 <<
"+++ Warning: " << thisLayerHits.size()
362 <<
" SimHits in key layer " << key_layer <<
"! +++ \n";
363 for (
unsigned i = 0;
i < thisLayerHits.size();
i++) {
365 <<
" SimHit # " <<
i << thisLayerHits[
i] <<
"\n";
368 matchedHit = thisLayerHits[0];
369 layerId = pli->getId();
376 if (hit_found ==
false) {
377 for (pli = allLayerInfo.begin(); pli != allLayerInfo.end(); pli++) {
379 if ((pli->getRecDigis()).
size() > 0 && (pli->getSimHits()).
size() > 0) {
381 matchedHit = (pli->getSimHits())[0];
382 layerId = pli->getId();
391 const CSCLayer* csclayer = geom_->layer(layerId);
404 int nearestStrip =
static_cast<int>(
strip);
407 <<
"+++ Warning: nearest strip, " << nearestStrip
409 <<
") interval; strip = " << strip <<
" +++\n";
412 int comp = ((strip - nearestStrip) < 0.5) ? 0 : 1;
413 nearestHS = 2*nearestStrip +
comp;
416 closestPhi = thisPoint.
phi();
417 closestEta = thisPoint.
eta();
418 ostringstream strstrm;
420 strstrm <<
"Matched cathode phi: " << closestPhi;
421 if (closestPhi < 0.) {
422 closestPhi += 2.*
M_PI;
424 strstrm <<
"(" << closestPhi <<
")";
427 strstrm <<
" eta: " << closestEta
428 <<
" on a layer " << layerId.
layer() <<
" (1-6);" 429 <<
" nearest strip: " << nearestStrip;
430 LogDebug(
"nearestHS") << strstrm.str();
446 <<
"+++ Warning: strip, " << strip
448 <<
") interval +++\n";
451 const CSCLayer* csclayer = geom_->layer(layerId);
461 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
static const int pattern2007_offset[CSCConstants::MAX_HALFSTRIPS_IN_PATTERN]
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)
Local3DPoint localPosition() const
static const int pattern2007[CSCConstants::NUM_CLCT_PATTERNS][CSCConstants::MAX_HALFSTRIPS_IN_PATTERN+2]
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::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::pair< const_iterator, const_iterator > Range
std::vector< PSimHit > PSimHitContainer
const CSCLayerGeometry * geometry() const