diff --git a/[refs] b/[refs] index 174bec5e4e510..6fca19ce101a8 100644 --- a/[refs] +++ b/[refs] @@ -1,3 +1,3 @@ --- refs/heads/gh-pages: ac155dadd83efa75cad55c0508a57a2b9dd3d66c -"refs/heads/CMSSW_7_1_X": af4b9d4693e70fc746e6cfa6c98912dda175b70d +"refs/heads/CMSSW_7_1_X": 399bd94c827b7665c5780328c9e6ab8116cb8f65 diff --git a/trunk/L1Trigger/CSCTrackFinder/src/CSCSectorReceiverLUT.cc b/trunk/L1Trigger/CSCTrackFinder/src/CSCSectorReceiverLUT.cc index d1a674891e85e..72d9394bdfe7b 100644 --- a/trunk/L1Trigger/CSCTrackFinder/src/CSCSectorReceiverLUT.cc +++ b/trunk/L1Trigger/CSCTrackFinder/src/CSCSectorReceiverLUT.cc @@ -21,43 +21,6 @@ lclphidat* CSCSectorReceiverLUT::me_lcl_phi = NULL; bool CSCSectorReceiverLUT::me_lcl_phi_loaded = false; -///KK -#include "CondFormats/L1TObjects/interface/L1MuCSCDTLut.h" -#include "CondFormats/DataRecord/interface/L1MuCSCDTLutRcd.h" -#include "CondFormats/L1TObjects/interface/L1MuCSCLocalPhiLut.h" -#include "CondFormats/DataRecord/interface/L1MuCSCLocalPhiLutRcd.h" -#include "CondFormats/L1TObjects/interface/L1MuCSCGlobalLuts.h" -#include "CondFormats/DataRecord/interface/L1MuCSCGlobalLutsRcd.h" -#include "FWCore/Framework/interface/ESHandle.h" -CSCSectorReceiverLUT::CSCSectorReceiverLUT(int endcap, int sector, int subsector, int station, - const edm::EventSetup& c, bool TMB07):_endcap(endcap),_sector(sector), - _subsector(subsector), - _station(station),isTMB07(TMB07) -{ - mb_global_phi = new gblphidat[1< localLUT; - c.get().get(localLUT); - const L1MuCSCLocalPhiLut *myConfigLocal_ = localLUT.product(); - memcpy((void*)me_lcl_phi,(void*)myConfigLocal_->lut(),(1<<19)*sizeof(lclphidat)); - - edm::ESHandle globalLUTs; - c.get().get(globalLUTs); - const L1MuCSCGlobalLuts *myConfigGlobal_ = globalLUTs.product(); - int mpc = (station==1?subsector-1:station); - if( mpc<0 || mpc>4 ) throw cms::Exception("Configuration error")<<"CSCSectorReceiverLUT|ctor: station="<phi_lut(mpc),(1<<19)*sizeof(gblphidat)); - memcpy((void*)me_global_eta,(void*)myConfigGlobal_->eta_lut(mpc),(1<<19)*sizeof(gbletadat)); - - edm::ESHandle dtLUTs; - c.get().get(dtLUTs); - const L1MuCSCDTLut *myConfigDT_ = dtLUTs.product(); - memcpy((void*)mb_global_phi,(void*)myConfigDT_->lut(0),(1<<19)*sizeof(gblphidat)); -} -/// CSCSectorReceiverLUT::CSCSectorReceiverLUT(int endcap, int sector, int subsector, int station, const edm::ParameterSet & pset, bool TMB07):_endcap(endcap),_sector(sector), @@ -289,13 +252,20 @@ double CSCSectorReceiverLUT::getGlobalPhiValue(const CSCLayer* thelayer, const u //LocalPoint lp; //GlobalPoint gp; - //thegeom = const_cast(thelayer->geometry()); - //lp = thegeom->stripWireGroupIntersection(strip, wire_group); - //gp = thelayer->surface().toGlobal(lp); - result = thelayer->centerOfStrip(strip).phi();//gp.phi(); - - if (result < 0.) result += 2.*M_PI; - + try + { + //thegeom = const_cast(thelayer->geometry()); + //lp = thegeom->stripWireGroupIntersection(strip, wire_group); + //gp = thelayer->surface().toGlobal(lp); + result = thelayer->centerOfStrip(strip).phi();//gp.phi(); + + if (result < 0.) result += 2.*M_PI; + } + catch(edm::Exception& e) + { + LogDebug("CSCSectorReceiverLUT|getGlobalPhiValue") << e.what(); + } + return result; } @@ -363,159 +333,166 @@ gblphidat CSCSectorReceiverLUT::calcGlobalPhiME(const gblphiadd& address) const << ", is out of bounds [0-, " << maxPhiL << ") +++\n"; } - thechamber = thegeom->chamber(_endcap,_station,_sector,_subsector,cscid); - if(thechamber) + try { - if(isTMB07) - { - layergeom = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER)->geometry()); - thelayer = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER)); - } - else - { - layergeom = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER_PRE_TMB07)->geometry()); - thelayer = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER_PRE_TMB07)); - } - const int nStrips = layergeom->numberOfStrips(); - // PhiL is the strip number converted into some units between 0 and - // 1023. When we did the conversion in fillLocalPhiTable(), we did - // not know for which chamber we do it (and, therefore, how many strips - // it has), and always used the maximum possible number of strips - // per chamber, MAX_NUM_STRIPS=80. Now, since we know the chamber id - // and how many strips the chamber has, we can re-adjust the scale. - //const double scale = static_cast(CSCConstants::MAX_NUM_STRIPS)/nStrips; - - int strip = 0, halfstrip = 0; - - halfstrip = static_cast(local_phi/binPhiL); - strip = halfstrip/2; - - // Find the phi width of the chamber and the position of its "left" - // (lower phi) edge (both in radians). - // Phi positions of the centers of the first and of the last strips - // in the chamber. - const double phi_f = getGlobalPhiValue(thelayer, 1, wire_group); - const double phi_l = getGlobalPhiValue(thelayer, nStrips, wire_group); - // Phi widths of the half-strips at both ends of the chamber; - // surprisingly, they are not the same. - const double hsWidth_f = fabs(getGlobalPhiValue(thelayer, 2, wire_group) - phi_f)/2.; - const double hsWidth_l = fabs(phi_l - getGlobalPhiValue(thelayer, nStrips - 1, wire_group))/2.; - - // The "natural" match between the strips and phi values -- when - // a larger strip number corresponds to a larger phi value, i.e. strips - // are counted clockwise if we look at them from the inside of the - // detector -- is reversed for some stations. At the moment, these - // are stations 3 and 4 of the 1st endcap, and stations 1 and 2 of - // the 2nd endcap. Instead of using - // if ((theEndcap == 1 && theStation <= 2) || - // (theEndcap == 2 && theStation >= 3)), - // we get the order from the phi values of the first and the last strip - // in a chamber, just in case the counting scheme changes in the future. - // Once we know how the strips are counted, we can go from the middle - // of the strips to their outer edges. - bool clockwiseOrder; - double leftEdge, rightEdge; - if (fabs(phi_f - phi_l) < M_PI) + thechamber = thegeom->chamber(_endcap,_station,_sector,_subsector,cscid); + if(thechamber) { - if (phi_f < phi_l) clockwiseOrder = true; - else clockwiseOrder = false; - } - else - { // the chamber crosses the phi = pi boundary - if (phi_f < phi_l) clockwiseOrder = false; - else clockwiseOrder = true; - } - if (clockwiseOrder) - { - leftEdge = phi_f - hsWidth_f; - rightEdge = phi_l + hsWidth_l; - } - else - { - leftEdge = phi_l - hsWidth_l; - rightEdge = phi_f + hsWidth_f; + if(isTMB07) + { + layergeom = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER)->geometry()); + thelayer = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER)); } - if (fabs(phi_f - phi_l) >= M_PI) {rightEdge += 2.*M_PI;} - //double chamberWidth = (rightEdge - leftEdge); - - // Chamber offset, relative to the edge of the sector. - //double chamberOffset = leftEdge - sectorOffset; - //if (chamberOffset < -M_PI) chamberOffset += 2*M_PI; - - double temp_phi = 0.0, strip_phi = 0.0, delta_phi = 0.0; - double distFromHalfStripCenter = 0.0, halfstripWidth = 0.0; - - if (strip < nStrips) - { - // Approximate distance from the center of the half-strip to the center - // of this phil bin, in units of half-strip width. - distFromHalfStripCenter = (local_phi+0.5)/binPhiL - halfstrip - 0.5; - // Half-strip width (in rad), calculated as the half-distance between - // the adjacent strips. Since in the current ORCA implementation - // the half-strip width changes from strip to strip, base the choice - // of the adjacent strip on the half-strip number. - if ((halfstrip%2 == 0 && halfstrip != 0) || halfstrip == 2*nStrips-1) { - halfstripWidth = - fabs(getGlobalPhiValue(thelayer, strip+1, wire_group) - getGlobalPhiValue(thelayer, strip, wire_group)) / 2.; - } else { - halfstripWidth = - fabs(getGlobalPhiValue(thelayer, strip+1, wire_group) - getGlobalPhiValue(thelayer, strip+2, wire_group)) / 2.; + layergeom = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER_PRE_TMB07)->geometry()); + thelayer = const_cast(thechamber->layer(CSCConstants::KEY_CLCT_LAYER_PRE_TMB07)); + } + const int nStrips = layergeom->numberOfStrips(); + // PhiL is the strip number converted into some units between 0 and + // 1023. When we did the conversion in fillLocalPhiTable(), we did + // not know for which chamber we do it (and, therefore, how many strips + // it has), and always used the maximum possible number of strips + // per chamber, MAX_NUM_STRIPS=80. Now, since we know the chamber id + // and how many strips the chamber has, we can re-adjust the scale. + //const double scale = static_cast(CSCConstants::MAX_NUM_STRIPS)/nStrips; + + int strip = 0, halfstrip = 0; + + halfstrip = static_cast(local_phi/binPhiL); + strip = halfstrip/2; + + // Find the phi width of the chamber and the position of its "left" + // (lower phi) edge (both in radians). + // Phi positions of the centers of the first and of the last strips + // in the chamber. + const double phi_f = getGlobalPhiValue(thelayer, 1, wire_group); + const double phi_l = getGlobalPhiValue(thelayer, nStrips, wire_group); + // Phi widths of the half-strips at both ends of the chamber; + // surprisingly, they are not the same. + const double hsWidth_f = fabs(getGlobalPhiValue(thelayer, 2, wire_group) - phi_f)/2.; + const double hsWidth_l = fabs(phi_l - getGlobalPhiValue(thelayer, nStrips - 1, wire_group))/2.; + + // The "natural" match between the strips and phi values -- when + // a larger strip number corresponds to a larger phi value, i.e. strips + // are counted clockwise if we look at them from the inside of the + // detector -- is reversed for some stations. At the moment, these + // are stations 3 and 4 of the 1st endcap, and stations 1 and 2 of + // the 2nd endcap. Instead of using + // if ((theEndcap == 1 && theStation <= 2) || + // (theEndcap == 2 && theStation >= 3)), + // we get the order from the phi values of the first and the last strip + // in a chamber, just in case the counting scheme changes in the future. + // Once we know how the strips are counted, we can go from the middle + // of the strips to their outer edges. + bool clockwiseOrder; + double leftEdge, rightEdge; + if (fabs(phi_f - phi_l) < M_PI) + { + if (phi_f < phi_l) clockwiseOrder = true; + else clockwiseOrder = false; + } + else + { // the chamber crosses the phi = pi boundary + if (phi_f < phi_l) clockwiseOrder = false; + else clockwiseOrder = true; } - // Correction for the strips crossing the 180 degree boundary. - if (halfstripWidth > M_PI/2.) halfstripWidth = M_PI - halfstripWidth; - // Phi at the center of the strip. - strip_phi = getGlobalPhiValue(thelayer, strip+1, wire_group); - // Distance between the center of the strip and the phil position. - delta_phi = halfstripWidth*(((halfstrip%2)-0.5)+distFromHalfStripCenter); if (clockwiseOrder) - temp_phi = strip_phi+ delta_phi; + { + leftEdge = phi_f - hsWidth_f; + rightEdge = phi_l + hsWidth_l; + } else - temp_phi = strip_phi- delta_phi; - } - else - { - // PhiL values that do not have corresponding strips (the chamber - // has less than 80 strips assumed in fillLocalPhi). It does not - // really matter what we do with these values; at the moment, just - // set them to the phis of the edges of the chamber. - if (clockwiseOrder) temp_phi = rightEdge; - else temp_phi = leftEdge; - } - - // Finally, subtract the sector offset and convert to the scale of - // the global phi. - - temp_phi -= sectorOffset; - - if (temp_phi < 0.) temp_phi += 2.*M_PI; - - temp_phi *= binPhiG; - - if (temp_phi < 0.) - { - result.global_phi = 0; - } - else if (temp_phi >= maxPhiG) - { + { + leftEdge = phi_l - hsWidth_l; + rightEdge = phi_f + hsWidth_f; + } + if (fabs(phi_f - phi_l) >= M_PI) {rightEdge += 2.*M_PI;} + //double chamberWidth = (rightEdge - leftEdge); + + // Chamber offset, relative to the edge of the sector. + //double chamberOffset = leftEdge - sectorOffset; + //if (chamberOffset < -M_PI) chamberOffset += 2*M_PI; + + double temp_phi = 0.0, strip_phi = 0.0, delta_phi = 0.0; + double distFromHalfStripCenter = 0.0, halfstripWidth = 0.0; + + if (strip < nStrips) + { + // Approximate distance from the center of the half-strip to the center + // of this phil bin, in units of half-strip width. + distFromHalfStripCenter = (local_phi+0.5)/binPhiL - halfstrip - 0.5; + // Half-strip width (in rad), calculated as the half-distance between + // the adjacent strips. Since in the current ORCA implementation + // the half-strip width changes from strip to strip, base the choice + // of the adjacent strip on the half-strip number. + if ((halfstrip%2 == 0 && halfstrip != 0) || halfstrip == 2*nStrips-1) { + halfstripWidth = + fabs(getGlobalPhiValue(thelayer, strip+1, wire_group) - getGlobalPhiValue(thelayer, strip, wire_group)) / 2.; + } + else + { + halfstripWidth = + fabs(getGlobalPhiValue(thelayer, strip+1, wire_group) - getGlobalPhiValue(thelayer, strip+2, wire_group)) / 2.; + } + // Correction for the strips crossing the 180 degree boundary. + if (halfstripWidth > M_PI/2.) halfstripWidth = M_PI - halfstripWidth; + // Phi at the center of the strip. + strip_phi = getGlobalPhiValue(thelayer, strip+1, wire_group); + // Distance between the center of the strip and the phil position. + delta_phi = halfstripWidth*(((halfstrip%2)-0.5)+distFromHalfStripCenter); + if (clockwiseOrder) + temp_phi = strip_phi+ delta_phi; + else + temp_phi = strip_phi- delta_phi; + } + else + { + // PhiL values that do not have corresponding strips (the chamber + // has less than 80 strips assumed in fillLocalPhi). It does not + // really matter what we do with these values; at the moment, just + // set them to the phis of the edges of the chamber. + if (clockwiseOrder) temp_phi = rightEdge; + else temp_phi = leftEdge; + } + + // Finally, subtract the sector offset and convert to the scale of + // the global phi. + + temp_phi -= sectorOffset; + + if (temp_phi < 0.) temp_phi += 2.*M_PI; + + temp_phi *= binPhiG; + + if (temp_phi < 0.) + { + result.global_phi = 0; + } + else if (temp_phi >= maxPhiG) + { result.global_phi = maxPhiG - 1; + } + else + { + result.global_phi = static_cast(temp_phi); + } + + LogDebug("CSCSectorReceiverLUT") + << "local_phi = " << local_phi + << " halfstrip = " << halfstrip << " strip = " << strip + << " distFromHalfStripCenter = " << distFromHalfStripCenter + << " halfstripWidth = " << halfstripWidth + << " strip phi = " << strip_phi/(M_PI/180.) + << " temp_phi = " << temp_phi*CSCTFConstants::SECTOR_DEG/maxPhiG + << " global_phi = " << result.global_phi + << " " << result.global_phi*CSCTFConstants::SECTOR_DEG/maxPhiG; + } - else - { - result.global_phi = static_cast(temp_phi); - } - - LogDebug("CSCSectorReceiverLUT") - << "local_phi = " << local_phi - << " halfstrip = " << halfstrip << " strip = " << strip - << " distFromHalfStripCenter = " << distFromHalfStripCenter - << " halfstripWidth = " << halfstripWidth - << " strip phi = " << strip_phi/(M_PI/180.) - << " temp_phi = " << temp_phi*CSCTFConstants::SECTOR_DEG/maxPhiG - << " global_phi = " << result.global_phi - << " " << result.global_phi*CSCTFConstants::SECTOR_DEG/maxPhiG; - + } + catch(edm::Exception& e) + { + edm::LogError("CSCSectorReceiverLUT|getGlobalPhiValue") << e.what(); } return result; @@ -655,71 +632,78 @@ double CSCSectorReceiverLUT::getGlobalEtaValue(const unsigned& thecscid, const u << " is out of bounds [0-" << numBins - 1 << "]\n"; phi_local = numBins - 1; } - const CSCChamber* thechamber = thegeom->chamber(_endcap,_station,_sector,_subsector,cscid); - if(thechamber) { - layerGeom = const_cast(thechamber->layer(CSCConstants::KEY_ALCT_LAYER)->geometry()); - const unsigned nWireGroups = layerGeom->numberOfWireGroups(); - - // Check wire group numbers; expect them to be counted from 0, as in - // CorrelatedLCTDigi class. - if (wire_group >= nWireGroups) { - edm::LogWarning("CSCSectorReceiverLUT|getEtaValue") - << "warning: wireGroup " << wire_group - << " is out of bounds [0-" << nWireGroups << ")\n"; - wire_group = nWireGroups - 1; - } - // Convert to [1; nWireGroups] range used in geometry methods. - wire_group += 1; - - // If me1ir_only is set, apply phi corrections only in ME1/1. - if (me1ir_only && - (_station != 1 || - CSCTriggerNumbering::ringFromTriggerLabels(_station, cscid) != 1)) - { - result = thechamber->layer(CSCConstants::KEY_ALCT_LAYER)->centerOfWireGroup(wire_group).eta(); - } - else { - const unsigned nStrips = layerGeom->numberOfStrips(); - const unsigned nStripsPerBin = CSCConstants::MAX_NUM_STRIPS/numBins; - /** - * Calculate Eta correction - */ - - // Check that no strips will be left out. - if (nStrips%numBins != 0 || CSCConstants::MAX_NUM_STRIPS%numBins != 0) - edm::LogWarning("CSCSectorReceiverLUT") - << "getGlobalEtaValue warning: number of strips " - << nStrips << " (" << CSCConstants::MAX_NUM_STRIPS - << ") is not divisible by numBins " << numBins - << " Station " << _station << " sector " << _sector - << " subsector " << _subsector << " cscid " << cscid << "\n"; - - unsigned maxStripPrevBin = 0, maxStripThisBin = 0; - unsigned correctionStrip; - LocalPoint lPoint; - GlobalPoint gPoint; - // Bins phi_local and find the the middle strip for each bin. - maxStripThisBin = nStripsPerBin * (phi_local+1); - if (maxStripThisBin <= nStrips) { - correctionStrip = nStripsPerBin/2 * (2*phi_local+1); - } - else { - // If the actual number of strips in the chamber is smaller than - // the number of strips corresponding to the right edge of this phi - // local bin, we take the middle strip between number of strips - // at the left edge of the bin and the actual number of strips. - maxStripPrevBin = nStripsPerBin * phi_local; - correctionStrip = (nStrips+maxStripPrevBin)/2; + try + { + const CSCChamber* thechamber = thegeom->chamber(_endcap,_station,_sector,_subsector,cscid); + if(thechamber) { + layerGeom = const_cast(thechamber->layer(CSCConstants::KEY_ALCT_LAYER)->geometry()); + const unsigned nWireGroups = layerGeom->numberOfWireGroups(); + + // Check wire group numbers; expect them to be counted from 0, as in + // CorrelatedLCTDigi class. + if (wire_group >= nWireGroups) { + edm::LogWarning("CSCSectorReceiverLUT|getEtaValue") + << "warning: wireGroup " << wire_group + << " is out of bounds [0-" << nWireGroups << ")\n"; + wire_group = nWireGroups - 1; + } + // Convert to [1; nWireGroups] range used in geometry methods. + wire_group += 1; + + // If me1ir_only is set, apply phi corrections only in ME1/1. + if (me1ir_only && + (_station != 1 || + CSCTriggerNumbering::ringFromTriggerLabels(_station, cscid) != 1)) + { + result = thechamber->layer(CSCConstants::KEY_ALCT_LAYER)->centerOfWireGroup(wire_group).eta(); + } + else { + const unsigned nStrips = layerGeom->numberOfStrips(); + const unsigned nStripsPerBin = CSCConstants::MAX_NUM_STRIPS/numBins; + /** + * Calculate Eta correction + */ + + // Check that no strips will be left out. + if (nStrips%numBins != 0 || CSCConstants::MAX_NUM_STRIPS%numBins != 0) + edm::LogWarning("CSCSectorReceiverLUT") + << "getGlobalEtaValue warning: number of strips " + << nStrips << " (" << CSCConstants::MAX_NUM_STRIPS + << ") is not divisible by numBins " << numBins + << " Station " << _station << " sector " << _sector + << " subsector " << _subsector << " cscid " << cscid << "\n"; + + unsigned maxStripPrevBin = 0, maxStripThisBin = 0; + unsigned correctionStrip; + LocalPoint lPoint; + GlobalPoint gPoint; + // Bins phi_local and find the the middle strip for each bin. + maxStripThisBin = nStripsPerBin * (phi_local+1); + if (maxStripThisBin <= nStrips) { + correctionStrip = nStripsPerBin/2 * (2*phi_local+1); + } + else { + // If the actual number of strips in the chamber is smaller than + // the number of strips corresponding to the right edge of this phi + // local bin, we take the middle strip between number of strips + // at the left edge of the bin and the actual number of strips. + maxStripPrevBin = nStripsPerBin * phi_local; + correctionStrip = (nStrips+maxStripPrevBin)/2; + } + + lPoint = layerGeom->stripWireGroupIntersection(correctionStrip, wire_group); + gPoint = thechamber->layer(CSCConstants::KEY_ALCT_LAYER)->surface().toGlobal(lPoint); + + // end calc of eta correction. + result = gPoint.eta(); + } } - - lPoint = layerGeom->stripWireGroupIntersection(correctionStrip, wire_group); - gPoint = thechamber->layer(CSCConstants::KEY_ALCT_LAYER)->surface().toGlobal(lPoint); - - // end calc of eta correction. - result = gPoint.eta(); } - } - + catch (cms::Exception &e) + { + LogDebug("CSCSectorReceiver|OutofBoundInput") << e.what(); + } + return std::fabs(result); } diff --git a/trunk/L1Trigger/CSCTrackFinder/src/CSCTFSectorProcessor.cc b/trunk/L1Trigger/CSCTrackFinder/src/CSCTFSectorProcessor.cc index 19d2a05abef8b..0bc580334d899 100644 --- a/trunk/L1Trigger/CSCTrackFinder/src/CSCTFSectorProcessor.cc +++ b/trunk/L1Trigger/CSCTrackFinder/src/CSCTFSectorProcessor.cc @@ -26,95 +26,53 @@ CSCTFSectorProcessor::CSCTFSectorProcessor(const unsigned& endcap, m_latency = pset.getParameter("CoreLatency"); m_minBX = pset.getParameter("MinBX"); m_maxBX = pset.getParameter("MaxBX"); + if( m_maxBX-m_minBX >= 7 ) edm::LogWarning("CSCTFTrackBuilder::ctor")<<" BX window width >= 7BX. Resetting m_maxBX="<<(m_maxBX=m_minBX+6); + // Uninitialize following parameters: m_bxa_depth = -1; - // try { - m_bxa_depth = pset.getParameter("BXAdepth"); - // } catch(...) { - // LogDebug("CSCTFSectorProcessor") << "Looking for BXAdepth in EventSetup for endcap="< config; c.get().get(config); - std::stringstream conf(config.product()->parameters()); - int eta_cnt=0; - while( !conf.eof() ){ - char buff[1024]; - conf.getline(buff,1024); - std::stringstream line(buff); - - std::string register_; line>>register_; - std::string chip_ ; line>>chip_; - std::string muon_; line>>muon_; - std::string writeValue_; line>>writeValue_; - std::string comments_; std::getline(line,comments_); - - if( register_=="CNT_ETA" && chip_=="SP" ){ - unsigned int value = strtol(writeValue_.c_str(),'\0',16); - eta_cnt = value; - } - if( register_=="DAT_ETA" && chip_=="SP" ){ - unsigned int value = strtol(writeValue_.c_str(),'\0',16); - if( eta_cnt< 8 ) m_etamin[eta_cnt ] = value; - if( eta_cnt>=8 && eta_cnt<16 ) m_etamax[eta_cnt-8 ] = value; - if( eta_cnt>=16 && eta_cnt<22 ) m_etawin[eta_cnt-16] = value; - // 4 line below is just an exaple (need to verify a sequence): - if( eta_cnt==22 ) m_mindphip = value; - if( eta_cnt==23 ) m_mindeta_accp = value; - if( eta_cnt==24 ) m_maxdeta_accp = value; - if( eta_cnt==25 ) m_maxdphi_accp = value; - eta_cnt++; - } - if( register_=="CSR_SCC" && chip_=="SP" ){ - unsigned int value = strtol(writeValue_.c_str(),'\0',16); - if( m_bxa_depth<0 ) m_bxa_depth = value&0x3; - if( m_allowALCTonly<0 ) m_allowALCTonly =(value&0x10)>>4; - if( m_allowCLCTonly<0 ) m_allowCLCTonly =(value&0x20)>>5; - if( m_preTrigger<0 ) m_preTrigger =(value&0x3000)>>12; - } - } + // And initialize only those parameters, which left uninitialized during construction +//std::cout<<"Initializing endcap: "<parameters((m_endcap-1)*2+(m_sector-1))<parameters((m_endcap-1)*2+(m_sector-1))); + // Check if parameters were not initialized in both: constuctor (from .cf? file) and initialize method (from EventSetup) if(m_bxa_depth <0) throw cms::Exception("CSCTFSectorProcessor")<<"BXAdepth parameter left uninitialized for endcap="<0 || trigger_on_ME1b>0 ||trigger_on_ME2>0 || + trigger_on_ME3>0 || trigger_on_ME4>0 ||trigger_on_MB1a>0 ||trigger_on_MB1d>0 ){ + if(singlesTrackPt<0) throw cms::Exception("CSCTFTrackBuilder")<<"singlesTrackPt parameter left uninitialized"; + if(singlesTrackOutput<0) throw cms::Exception("CSCTFTrackBuilder")<<"singlesTrackOutput parameter left uninitialized"; + } + if(QualityEnableME1a<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME1a parameter left uninitialized"; + if(QualityEnableME1b<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME1b parameter left uninitialized"; + if(QualityEnableME1c<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME1c parameter left uninitialized"; + if(QualityEnableME1d<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME1d parameter left uninitialized"; + if(QualityEnableME1e<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME1e parameter left uninitialized"; + if(QualityEnableME1f<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME1f parameter left uninitialized"; + if(QualityEnableME2a<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME2a parameter left uninitialized"; + if(QualityEnableME2b<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME2b parameter left uninitialized"; + if(QualityEnableME2c<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME2c parameter left uninitialized"; + if(QualityEnableME3a<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME3a parameter left uninitialized"; + if(QualityEnableME3b<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME3b parameter left uninitialized"; + if(QualityEnableME3c<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME3c parameter left uninitialized"; + if(QualityEnableME4a<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME4a parameter left uninitialized"; + if(QualityEnableME4b<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME4b parameter left uninitialized"; + if(QualityEnableME4c<0) throw cms::Exception("CSCTFTrackBuilder")<<"QualityEnableME4c parameter left uninitialized"; +} + +void CSCTFSectorProcessor::readParameters(const edm::ParameterSet& pset){ + if(m_bxa_depth<0) + try { + m_bxa_depth = pset.getParameter("BXAdepth"); + } catch(...) {} + if(m_allowALCTonly<0) + try { + m_allowALCTonly = ( pset.getParameter("AllowALCTonly") ? 1 : 0 ); + } catch(...) {} + if(m_allowCLCTonly<0) + try { + m_allowCLCTonly = ( pset.getParameter("AllowCLCTonly") ? 1 : 0 ); + } catch(...) {} + if(m_preTrigger<0) + try { + m_preTrigger = pset.getParameter("PreTrigger"); + } catch(...) {} + + std::vector::const_iterator iter; + int index=0; + if(m_etamax[0]<0) + try { + std::vector etawins = pset.getParameter >("EtaWindows"); + for(iter=etawins.begin(),index=0; iter!=etawins.end()&&index<6; iter++,index++) m_etawin[index] = *iter; + } catch(...) { } + if(m_etamin[0]<0) + try { + std::vector etamins = pset.getParameter >("EtaMin"); + for(iter=etamins.begin(),index=0; iter!=etamins.end()&&index<8; iter++,index++) m_etamin[index] = *iter; + } catch(...) { } + if(m_etamax[0]<0) + try { + std::vector etamaxs = pset.getParameter >("EtaMax"); + for(iter=etamaxs.begin(),index=0; iter!=etamaxs.end()&&index<8; iter++,index++) m_etamax[index] = *iter; + } catch(...) { } + if(m_mindphip<0) + try { + m_mindphip = pset.getParameter("mindphip"); + } catch(...) { } + if(m_mindeta_accp<0) + try { + m_mindeta_accp = pset.getParameter("mindeta_accp"); + } catch(...) { } + if(m_maxdeta_accp<0) + try { + m_maxdeta_accp = pset.getParameter("maxdeta_accp"); + } catch(...) { } + if(m_maxdphi_accp<0) + try { + m_maxdphi_accp = pset.getParameter("maxdphi_accp"); + } catch(...) { } + if(kill_fiber<0) + try { + kill_fiber = pset.getParameter("kill_fiber"); + } catch(...) {} + if(run_core<0) + try { + run_core = pset.getParameter("run_core"); + } catch(...) {} + if(trigger_on_ME1a<0) + try { + trigger_on_ME1a = pset.getParameter("trigger_on_ME1a"); + } catch(...) {} + if(trigger_on_ME1b<0) + try { + trigger_on_ME1b = pset.getParameter("trigger_on_ME1b"); + } catch(...) {} + if(trigger_on_ME2<0) + try { + trigger_on_ME2 = pset.getParameter("trigger_on_ME2"); + } catch(...) {} + if(trigger_on_ME3<0) + try { + trigger_on_ME3 = pset.getParameter("trigger_on_ME3"); + } catch(...) {} + if(trigger_on_ME4<0) + try { + trigger_on_ME4 = pset.getParameter("trigger_on_ME4"); + } catch(...) {} + if(trigger_on_MB1a<0) + try { + trigger_on_MB1a = pset.getParameter("trigger_on_MB1a"); + } catch(...) {} + if(trigger_on_MB1d<0) + try { + trigger_on_MB1d = pset.getParameter("trigger_on_MB1d"); + } catch(...) {} + if(singlesTrackPt<0) + try { + singlesTrackPt = pset.getParameter("singlesTrackPt"); + } catch(...) {} + if(singlesTrackOutput<0) + try { + singlesTrackOutput = pset.getParameter("singlesTrackOutput"); + } catch(...) {} + if(QualityEnableME1a<0) + try { + QualityEnableME1a = pset.getParameter("QualityEnableME1a"); + } catch(...) {} + if(QualityEnableME1b<0) + try { + QualityEnableME1b = pset.getParameter("QualityEnableME1b"); + } catch(...) {} + if(QualityEnableME1c<0) + try { + QualityEnableME1c = pset.getParameter("QualityEnableME1c"); + } catch(...) {} + if(QualityEnableME1d<0) + try { + QualityEnableME1d = pset.getParameter("QualityEnableME1d"); + } catch(...) {} + if(QualityEnableME1e<0) + try { + QualityEnableME1e = pset.getParameter("QualityEnableME1e"); + } catch(...) {} + if(QualityEnableME1f<0) + try { + QualityEnableME1f = pset.getParameter("QualityEnableME1f"); + } catch(...) {} + if(QualityEnableME2a<0) + try { + QualityEnableME2a = pset.getParameter("QualityEnableME2a"); + } catch(...) {} + if(QualityEnableME2b<0) + try { + QualityEnableME2b = pset.getParameter("QualityEnableME2b"); + } catch(...) {} + if(QualityEnableME2c<0) + try { + QualityEnableME2c = pset.getParameter("QualityEnableME2c"); + } catch(...) {} + if(QualityEnableME3a<0) + try { + QualityEnableME3a = pset.getParameter("QualityEnableME3a"); + } catch(...) {} + if(QualityEnableME3b<0) + try { + QualityEnableME3b = pset.getParameter("QualityEnableME3b"); + } catch(...) {} + if(QualityEnableME3c<0) + try { + QualityEnableME3c = pset.getParameter("QualityEnableME3c"); + } catch(...) {} + if(QualityEnableME4a<0) + try { + QualityEnableME4a = pset.getParameter("QualityEnableME4a"); + } catch(...) {} + if(QualityEnableME4b<0) + try { + QualityEnableME4b = pset.getParameter("QualityEnableME4b"); + } catch(...) {} + if(QualityEnableME4c<0) + try { + QualityEnableME4c = pset.getParameter("QualityEnableME4c"); + } catch(...) {} } CSCTFSectorProcessor::~CSCTFSectorProcessor() @@ -239,13 +330,57 @@ bool CSCTFSectorProcessor::run(const CSCTriggerContainer& stub if( !ptLUT_ ) throw cms::Exception("Initialize CSC TF LUTs first (missed call to CSCTFTrackProducer::beginJob?)")<<"CSCTFSectorProcessor::run"; - for(int i = 0; i < 5; ++i) - if(!srLUTs_[FPGAs[i]]) - throw cms::Exception("Initialize CSC TF LUTs first (missed call to CSCTFTrackProducer::beginJob?)")<<"CSCTFSectorProcessor::run"; l1_tracks.clear(); dt_stubs.clear(); + stub_vec_filtered.clear(); + + std::vector stub_vec = stubs.get(); + + /** STEP ZERO + * Remove stubs, which were masked out by kill_fiber or QualityEnable parameters + */ + for(std::vector::const_iterator itr=stub_vec.begin(); itr!=stub_vec.end(); itr++) + switch( itr->station() ){ + case 5: stub_vec_filtered.push_back(*itr); break; // DT stubs get filtered by the core controll register + case 4: + switch( itr->getMPCLink() ){ + case 3: if( (kill_fiber&0x4000)==0 && QualityEnableME4c&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 2: if( (kill_fiber&0x2000)==0 && QualityEnableME4b&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 1: if( (kill_fiber&0x1000)==0 && QualityEnableME4a&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<getMPCLink()<<"\n"; + } + break; + case 3: + switch( itr->getMPCLink() ){ + case 3: if( (kill_fiber&0x0800)==0 && QualityEnableME3c&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 2: if( (kill_fiber&0x0400)==0 && QualityEnableME3b&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 1: if( (kill_fiber&0x0200)==0 && QualityEnableME3a&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<getMPCLink()<<"\n"; + } + break; + case 2: + switch( itr->getMPCLink() ){ + case 3: if( (kill_fiber&0x0100)==0 && QualityEnableME2c&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 2: if( (kill_fiber&0x0080)==0 && QualityEnableME2b&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 1: if( (kill_fiber&0x0040)==0 && QualityEnableME2a&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<getMPCLink()<<"\n"; + } + break; + case 1: + switch( itr->getMPCLink() + (3*(CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(itr->getDetId().rawId())) - 1)) ){ + case 6: if( (kill_fiber&0x0020)==0 && QualityEnableME1f&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 5: if( (kill_fiber&0x0010)==0 && QualityEnableME1e&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 4: if( (kill_fiber&0x0008)==0 && QualityEnableME1d&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 3: if( (kill_fiber&0x0004)==0 && QualityEnableME1c&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 2: if( (kill_fiber&0x0002)==0 && QualityEnableME1b&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + case 1: if( (kill_fiber&0x0001)==0 && QualityEnableME1a&(1<getQuality()) ) stub_vec_filtered.push_back(*itr); break; + default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<getMPCLink()<<"\n"; + } + break; + default: edm::LogWarning("CSCTFSectorProcessor::run()") << "Invalid station # encountered: "<station()<<"\n"; + } /** STEP ONE * We take stubs from the MPC and assign their eta and phi @@ -255,11 +390,7 @@ bool CSCTFSectorProcessor::run(const CSCTriggerContainer& stub * After this we append the stubs gained from the DT system. */ - std::vector stub_vec = stubs.get(); - std::vector::iterator itr = stub_vec.begin(); - std::vector::const_iterator end = stub_vec.end(); - - for(; itr != end; itr++) + for(std::vector::iterator itr=stub_vec_filtered.begin(); itr!=stub_vec_filtered.end(); itr++) { if(itr->station() != 5) { @@ -267,17 +398,17 @@ bool CSCTFSectorProcessor::run(const CSCTriggerContainer& stub unsigned fpga = (id.station() == 1) ? CSCTriggerNumbering::triggerSubSectorFromLabels(id) - 1 : id.station(); lclphidat lclPhi; - // try { + try { lclPhi = srLUTs_[FPGAs[fpga]]->localPhi(itr->getStrip(), itr->getPattern(), itr->getQuality(), itr->getBend()); - // } catch(...) { bzero(&lclPhi,sizeof(lclPhi)); } + } catch(...) { bzero(&lclPhi,sizeof(lclPhi)); } gblphidat gblPhi; - // try { + try { gblPhi = srLUTs_[FPGAs[fpga]]->globalPhiME(lclPhi.phi_local, itr->getKeyWG(), itr->cscid()); - // } catch(...) { bzero(&gblPhi,sizeof(gblPhi)); } + } catch(...) { bzero(&gblPhi,sizeof(gblPhi)); } gbletadat gblEta; - // try { + try { gblEta = srLUTs_[FPGAs[fpga]]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, itr->getKeyWG(), itr->cscid()); - // } catch(...) { bzero(&gblEta,sizeof(gblEta)); } + } catch(...) { bzero(&gblEta,sizeof(gblEta)); } itr->setEtaPacked(gblEta.global_eta); itr->setPhiPacked(gblPhi.global_phi); @@ -289,7 +420,7 @@ bool CSCTFSectorProcessor::run(const CSCTriggerContainer& stub } } - CSCTriggerContainer processedStubs(stub_vec); + CSCTriggerContainer processedStubs(stub_vec_filtered); /** STEP TWO * We take the stubs filled by the SR LUTs and load them @@ -299,50 +430,112 @@ bool CSCTFSectorProcessor::run(const CSCTriggerContainer& stub std::vector tftks; - core_->loadData(processedStubs, m_endcap, m_sector, m_minBX, m_maxBX); - - if( core_->run(m_endcap, m_sector, m_latency, - m_etamin[0], m_etamin[1], m_etamin[2], m_etamin[3], - m_etamin[4], m_etamin[5], m_etamin[6], m_etamin[7], - m_etamax[0], m_etamax[1], m_etamax[2], m_etamax[3], - m_etamax[4], m_etamax[5], m_etamax[6], m_etamax[7], - m_etawin[0], m_etawin[1], m_etawin[2], - m_etawin[3], m_etawin[4], m_etawin[5], - m_mindphip, m_mindeta_accp, m_maxdeta_accp, m_maxdphi_accp, - m_bxa_depth, m_allowALCTonly, m_allowCLCTonly, m_preTrigger, - m_minBX, m_maxBX) ) - { - l1_tracks = core_->tracks(); - } - - tftks = l1_tracks.get(); + if(run_core){ + core_->loadData(processedStubs, m_endcap, m_sector, m_minBX, m_maxBX); + + if( core_->run(m_endcap, m_sector, m_latency, + m_etamin[0], m_etamin[1], m_etamin[2], m_etamin[3], + m_etamin[4], m_etamin[5], m_etamin[6], m_etamin[7], + m_etamax[0], m_etamax[1], m_etamax[2], m_etamax[3], + m_etamax[4], m_etamax[5], m_etamax[6], m_etamax[7], + m_etawin[0], m_etawin[1], m_etawin[2], + m_etawin[3], m_etawin[4], m_etawin[5], + m_mindphip, m_mindeta_accp, m_maxdeta_accp, m_maxdphi_accp, + m_bxa_depth, m_allowALCTonly, m_allowCLCTonly, m_preTrigger, + m_minBX, m_maxBX) ) + { + l1_tracks = core_->tracks(); + } - /** STEP THREE - * Now that we have the found tracks from the core, - * we must assign their Pt. - */ + tftks = l1_tracks.get(); - std::vector::iterator titr = tftks.begin(); + /** STEP THREE + * Now that we have the found tracks from the core, + * we must assign their Pt. + */ - for(; titr != tftks.end(); titr++) - { - ptadd thePtAddress(titr->ptLUTAddress()); - ptdat thePtData = ptLUT_->Pt(thePtAddress); + std::vector::iterator titr = tftks.begin(); - if(thePtAddress.track_fr) - { - titr->setRank(thePtData.front_rank); - titr->setChargeValidPacked(thePtData.charge_valid_front); - } - else - { - titr->setRank(thePtData.rear_rank); - titr->setChargeValidPacked(thePtData.charge_valid_rear); - } + for(; titr != tftks.end(); titr++) + { + ptadd thePtAddress(titr->ptLUTAddress()); + ptdat thePtData = ptLUT_->Pt(thePtAddress); + + if(thePtAddress.track_fr) + { + titr->setRank(thePtData.front_rank); + titr->setChargeValidPacked(thePtData.charge_valid_front); + } + else + { + titr->setRank(thePtData.rear_rank); + titr->setChargeValidPacked(thePtData.charge_valid_rear); + } } + } //end of if(run_core) l1_tracks = tftks; + + // Add-on for singles: + CSCTriggerContainer myStubContainer[7]; //[BX] + // Loop over CSC LCTs if triggering on them: + if( trigger_on_ME1a || trigger_on_ME1b || trigger_on_ME2 || trigger_on_ME3 || trigger_on_ME4 || trigger_on_MB1a || trigger_on_MB1d ) + for(std::vector::iterator itr=stub_vec_filtered.begin(); itr!=stub_vec_filtered.end(); itr++){ + int station = itr->station()-1; + int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(itr->getDetId().rawId())); + int mpc = ( subSector ? subSector-1 : station+1 ); + if( (mpc==0&&trigger_on_ME1a) || (mpc==1&&trigger_on_ME1b) || + (mpc==2&&trigger_on_ME2) || (mpc==3&&trigger_on_ME3) || + (mpc==4&&trigger_on_ME4) || + (mpc==5&& ( (trigger_on_MB1a&&subSector%2==1) || (trigger_on_MB1d&&subSector%2==0) ) ) ){ + int bx = itr->getBX() - m_minBX; + if( bx<0 || bx>=7 ) edm::LogWarning("CSCTFTrackBuilder::buildTracks()") << " LCT BX is out of ["<getBX(); + else + if( itr->isValid() ) myStubContainer[bx].push_back(*itr); + } + } + + // Core's input was loaded in a relative time window BX=[0-7) + // To relate it to time window of tracks (centred at BX=0) we introduce a shift: + int shift = (m_maxBX + m_minBX)/2 - m_minBX; + + // Now we put tracks from singles in a certain bx + // if there were no tracks from the core in this endcap/sector/bx + CSCTriggerContainer tracksFromSingles; + for(int bx=0; bx<7; bx++) + if( myStubContainer[bx].get().size() ){ // VP this bx + bool coreTrackExists = false; + // tracks are not ordered to be accessible by bx => loop them all + std::vector tracks = l1_tracks.get(); + for(std::vector::iterator trk=tracks.begin(); trkBX() == bx-shift && + trk->outputLink() == singlesTrackOutput ){ + coreTrackExists = true; + break; + } + if( coreTrackExists == false ){ + csc::L1TrackId trackId(m_endcap,m_sector); + csc::L1Track track(trackId); + track.setRank(singlesTrackPt&0x1F); + track.setBx(bx-shift); + track.setPtPacked(singlesTrackPt); + track.setQualityPacked((singlesTrackPt&0x60)>>5); + track.setChargeValidPacked((singlesTrackPt&0x80)>>7); + track.setPtLUTAddress(15<<16); + //CSCCorrelatedLCTDigiCollection singles; + //std::vector stubs = myStubContainer[bx].get(); + //for(std::vector::const_iterator st_iter=stubs.begin(); + // st_iter!=stubs.end(); st_iter++) + // singles.insertDigi(CSCDetId(st_iter->getDetId().rawId()),*st_iter); + //tracksFromSingles.push_back(L1CSCTrack(track,singles)); + tracksFromSingles.push_back(track); + } + } + std::vector single_tracks = tracksFromSingles.get(); + if( single_tracks.size() ) l1_tracks.push_many(single_tracks); + // End of add-on for singles + return (l1_tracks.get().size() > 0); } diff --git a/trunk/L1Trigger/CSCTrackFinder/src/CSCTFTrackBuilder.cc b/trunk/L1Trigger/CSCTrackFinder/src/CSCTFTrackBuilder.cc index 60d0f3453f29b..ade56bd102212 100644 --- a/trunk/L1Trigger/CSCTrackFinder/src/CSCTFTrackBuilder.cc +++ b/trunk/L1Trigger/CSCTrackFinder/src/CSCTFTrackBuilder.cc @@ -30,91 +30,6 @@ CSCTFTrackBuilder::CSCTFTrackBuilder(const edm::ParameterSet& pset, bool TMB07, scales, ptScale); } } - // Uninitialize following parameters: - run_core = -1; - trigger_on_ME1a = -1; - trigger_on_ME1b = -1; - trigger_on_ME2 = -1; - trigger_on_ME3 = -1; - trigger_on_ME4 = -1; - trigger_on_MB1a = -1; - trigger_on_MB1d = -1; - singlesTrackPt = -1; - singlesTrackOutput = -1; - - // try { - run_core = pset.getParameter("run_core"); - LogDebug("CSCTFTrackBuilder") << "Using run_core configuration parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for run_core parameter in EventSetup"; -// } - -// try { - trigger_on_ME1a = pset.getParameter("trigger_on_ME1a"); - LogDebug("CSCTFTrackBuilder") << "Using trigger_on_ME1a parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for trigger_on_ME1a parameter in EventSetup"; -// } - -// try { - trigger_on_ME1b = pset.getParameter("trigger_on_ME1b"); - LogDebug("CSCTFTrackBuilder") << "Using trigger_on_ME1b parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for trigger_on_ME1b parameter in EventSetup"; -// } - -// try { - trigger_on_ME2 = pset.getParameter("trigger_on_ME2"); - LogDebug("CSCTFTrackBuilder") << "Using trigger_on_ME2 parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for trigger_on_ME2 parameter in EventSetup"; -// } - -// try { - trigger_on_ME3 = pset.getParameter("trigger_on_ME3"); - LogDebug("CSCTFTrackBuilder") << "Using trigger_on_ME3 parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for trigger_on_ME3 parameter in EventSetup"; -// } - -// try { - trigger_on_ME4 = pset.getParameter("trigger_on_ME4"); - LogDebug("CSCTFTrackBuilder") << "Using trigger_on_ME4 parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for trigger_on_ME4 parameter in EventSetup"; -// } - -// try { - trigger_on_MB1a = pset.getParameter("trigger_on_MB1a"); - LogDebug("CSCTFTrackBuilder") << "Using trigger_on_MB1a parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for trigger_on_MB1a parameter in EventSetup"; -// } - -// try { - trigger_on_MB1d = pset.getParameter("trigger_on_MB1d"); - LogDebug("CSCTFTrackBuilder") << "Using trigger_on_MB1d parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for trigger_on_MB1d parameter in EventSetup"; -// } - -// try { - singlesTrackPt = pset.getParameter("singlesTrackPt"); - LogDebug("CSCTFTrackBuilder") << "Using singlesTrackPt parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for singlesTrackPt parameter in EventSetup"; -// } - -// try { - singlesTrackOutput = pset.getParameter("singlesTrackOutput"); - LogDebug("CSCTFTrackBuilder") << "Using singlesTrackOutput parameter from .cfi file"; -// } catch(...) { -// LogDebug("CSCTFTrackBuilder") << "Looking for singlesTrackOutput parameter in EventSetup"; -// } - - m_minBX = pset.getParameter("MinBX"); - m_maxBX = pset.getParameter("MaxBX"); - if( m_maxBX-m_minBX >= 7 ) edm::LogWarning("CSCTFTrackBuilder::ctor")<<" BX window width >= 7BX. Resetting m_maxBX="<<(m_maxBX=m_minBX+6); } void CSCTFTrackBuilder::initialize(const edm::EventSetup& c){ @@ -126,59 +41,8 @@ void CSCTFTrackBuilder::initialize(const edm::EventSetup& c){ my_SPs[e-1][s-1]->initialize(c); } } - - edm::ESHandle config; - c.get().get(config); - std::stringstream conf(config.product()->parameters()); - while( !conf.eof() ){ - char buff[1024]; - conf.getline(buff,1024); - std::stringstream line(buff); - - std::string register_; line>>register_; - std::string chip_; line>>chip_; - std::string muon_; line>>muon_; - std::string writeValue_; line>>writeValue_; - std::string comments_; std::getline(line,comments_); - - if( register_=="CSR_REQ" && chip_=="SP" ){ - unsigned int value = strtol(writeValue_.c_str(),'\0',16); - // Initializeing in constructor from .cf? file always have priority over EventSetup - if(run_core<0) run_core = value&0x8000; - if(trigger_on_ME1a<0) trigger_on_ME1a = value&0x0001; - if(trigger_on_ME1b<0) trigger_on_ME1b = value&0x0002; - if(trigger_on_ME2 <0) trigger_on_ME2 = value&0x0004; - if(trigger_on_ME3 <0) trigger_on_ME3 = value&0x0008; - if(trigger_on_ME4 <0) trigger_on_ME4 = value&0x0010; - if(trigger_on_MB1a<0) trigger_on_MB1a = value&0x0100; - if(trigger_on_MB1d<0) trigger_on_MB1d = value&0x0200; - } - if( register_=="DAT_FTR" && chip_=="SP" ){ - unsigned int value = strtol(writeValue_.c_str(),'\0',16); - // Initializeing in constructor from .cf? file always have priority over EventSetup - if(singlesTrackPt<0) singlesTrackPt = value; // 0x1F - rank, 0x60 - Q1,Q0, 0x80 - charge - } - if( register_=="CSR_SFC" && chip_=="SP" ){ - unsigned int value = strtol(writeValue_.c_str(),'\0',16); - // Initializeing in constructor from .cf? file always have priority over EventSetup - if(singlesTrackOutput<0) singlesTrackOutput = (value&0x3000)>>12; - } - } - // Check if parameters were not initialized in both: constuctor (from .cf? file) and initialize method (from EventSetup) - if(run_core <0) throw cms::Exception("CSCTFTrackBuilder")<<"run_core parameter left uninitialized"; - if(trigger_on_ME1a<0) throw cms::Exception("CSCTFTrackBuilder")<<"trigger_on_ME1a parameter left uninitialized"; - if(trigger_on_ME1b<0) throw cms::Exception("CSCTFTrackBuilder")<<"trigger_on_ME1b parameter left uninitialized"; - if(trigger_on_ME2 <0) throw cms::Exception("CSCTFTrackBuilder")<<"trigger_on_ME2 parameter left uninitialized"; - if(trigger_on_ME3 <0) throw cms::Exception("CSCTFTrackBuilder")<<"trigger_on_ME3 parameter left uninitialized"; - if(trigger_on_ME4 <0) throw cms::Exception("CSCTFTrackBuilder")<<"trigger_on_ME4 parameter left uninitialized"; - if(trigger_on_MB1a<0) throw cms::Exception("CSCTFTrackBuilder")<<"trigger_on_MB1a parameter left uninitialized"; - if(trigger_on_MB1d<0) throw cms::Exception("CSCTFTrackBuilder")<<"trigger_on_MB1d parameter left uninitialized"; - if( trigger_on_ME1a>0 || trigger_on_ME1b>0 ||trigger_on_ME2>0 || - trigger_on_ME3>0 || trigger_on_ME4>0 ||trigger_on_MB1a>0 ||trigger_on_MB1d>0 ){ - if(singlesTrackPt<0) throw cms::Exception("CSCTFTrackBuilder")<<"singlesTrackPt parameter left uninitialized"; - if(singlesTrackOutput<0) throw cms::Exception("CSCTFTrackBuilder")<<"singlesTrackOutput parameter left uninitialized"; - } } + CSCTFTrackBuilder::~CSCTFTrackBuilder() { delete my_dtrc; @@ -221,22 +85,20 @@ void CSCTFTrackBuilder::buildTracks(const CSCCorrelatedLCTDigiCollection* lcts, CSCTriggerContainer dtstubs = my_dtrc->process(dttrig); stub_list.push_many(dtstubs); - if(run_core){ - // run each sector processor in the TF - for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e) - { - for(int s = CSCTriggerNumbering::minTriggerSectorId(); - s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s) - { - CSCTriggerContainer current_e_s = stub_list.get(e, s); - if(my_SPs[e-1][s-1]->run(current_e_s)) - { - std::vector theTracks = my_SPs[e-1][s-1]->tracks().get(); - trks.insert(trks.end(), theTracks.begin(), theTracks.end()); - } - stubs_to_dt->push_many(my_SPs[e-1][s-1]->dtStubs()); // send stubs whether or not we find a track!!! - } - } + // run each sector processor in the TF + for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e) + { + for(int s = CSCTriggerNumbering::minTriggerSectorId(); + s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s) + { + CSCTriggerContainer current_e_s = stub_list.get(e, s); + if(my_SPs[e-1][s-1]->run(current_e_s)) + { + std::vector theTracks = my_SPs[e-1][s-1]->tracks().get(); + trks.insert(trks.end(), theTracks.begin(), theTracks.end()); + } + stubs_to_dt->push_many(my_SPs[e-1][s-1]->dtStubs()); // send stubs whether or not we find a track!!! + } } // Now to combine tracks with their track stubs and send them off. @@ -247,8 +109,7 @@ void CSCTFTrackBuilder::buildTracks(const CSCCorrelatedLCTDigiCollection* lcts, for(; titr != trks.end(); titr++) { tcitr->first = (*titr); - - std::vector possible_stubs = stub_list.get(titr->endcap(), titr->sector()); + std::vector possible_stubs = my_SPs[titr->endcap()-1][titr->sector()-1]->filteredStubs(); std::vector::const_iterator tkstbs = possible_stubs.begin(); int me1ID = titr->me1ID(); @@ -299,98 +160,5 @@ void CSCTFTrackBuilder::buildTracks(const CSCCorrelatedLCTDigiCollection* lcts, tcitr++; // increment to next track in the collection } - // Add-on for singles: - CSCCorrelatedLCTDigiCollection myLCTcontainer[2][6][7]; //[endcap][sector][BX] - // Loop over CSC LCTs if triggering on them: - if( trigger_on_ME1a || trigger_on_ME1b || trigger_on_ME2 || trigger_on_ME3 || trigger_on_ME4 ){ - for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=lcts->begin(); csc!=lcts->end(); csc++){ - CSCCorrelatedLCTDigiCollection::Range range = lcts->get((*csc).first); - for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range.first; lct!=range.second; lct++){ - int endcap = (*csc).first.endcap()-1; - int sector = (*csc).first.triggerSector()-1; - int station = (*csc).first.station()-1; - int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first); - if( sector<0 || sector>6 || station<0 || station>3 || subSector<0 || subSector>2 || endcap<0 || endcap>1 ){ - edm::LogWarning("CSCTFTrackBuilder::buildTracks()")<<" CSC digi are out of range"; - continue; - } -///std::cout<<"Found LCT in endcap="<getBX(); - else - if( lct->isValid() ){ - myLCTcontainer[endcap][sector][bx].put(range,(*csc).first); - break; //we break out of the loop because we put whole range if we encounter VP - } - } - } - } - } - // Loop over DT stubs if triggering on them: - if( trigger_on_MB1a || trigger_on_MB1d ){ - std::vector _dtstubs = dtstubs.get(); - for(std::vector::const_iterator stub=_dtstubs.begin(); stub!=_dtstubs.end(); stub++){ - int endcap = stub->endcap() -1; - int sector = stub->sector() -1; - int station = stub->station()-1; - int subSector = stub->subsector(); -///std::cout<<"Found DT in endcap="<getDigi(); //this is not a real LCT, but just a representation of DT information - if( (trigger_on_MB1a && subSector%2==1) || //MB1a and MB1b may be swaped here! - (trigger_on_MB1d && subSector%2==0) ){ - int bx = lct->getBX() - m_minBX; - if( bx<0 || bx>=7 ) edm::LogWarning("CSCTFTrackBuilder::buildTracks()") << " DT stub BX is out of ["<getBX(); - else - if( lct->isValid() ) - //Construct fake CSCDetId (impossible to put DTDetId in CSC containers) - myLCTcontainer[endcap][sector][bx].insertDigi(CSCDetId(endcap,station-4+1,subSector%2+1,0),*lct); - } - } - } - - // Core's input was loaded in a relative time window BX=[0-7) - // To relate it to time window of tracks (centred at BX=0) we introduce a shift: - int shift = (m_maxBX + m_minBX)/2 - m_minBX; - - // Now we put tracks from singles in a certain endcap/sector/bx only - // if there were no tracks from the core in this endcap/sector/bx - L1CSCTrackCollection tracksFromSingles; - for(unsigned int endcap=0; endcap<2; endcap++) - for(unsigned int sector=0; sector<6; sector++) - for(int bx=0; bx<7; bx++) - if( myLCTcontainer[endcap][sector][bx].begin() != - myLCTcontainer[endcap][sector][bx].end() ){ // VP was detected in endcap/sector/bx - bool coreTrackExists = false; - // tracks are not ordered to be accessible by endcap/sector/bx => loop them all - for(L1CSCTrackCollection::iterator trk=trkcoll->begin(); trkend(); trk++) - if( trk->first.endcap()-1 == endcap && - trk->first.sector()-1 == sector && - trk->first.BX() == bx-shift && - trk->first.outputLink() == singlesTrackOutput ){ - coreTrackExists = true; - break; - } - if( coreTrackExists == false ){ - csc::L1TrackId trackId(endcap+1,sector+1); - csc::L1Track track(trackId); - track.setRank(singlesTrackPt&0x1F); - track.setBx(bx-shift); - //track.setPtPacked(singlesTrackPt); - //track.setQualityPacked(singlesTrackPt); - //track.setChargeValidPacked(); - tracksFromSingles.push_back(L1CSCTrack(track,myLCTcontainer[endcap][sector][bx])); - } - } - if( tracksFromSingles.size() ) - trkcoll->insert( trkcoll->end(), tracksFromSingles.begin(), tracksFromSingles.end() ); - // End of add-on for singles }