2942 map<CSCDetId, float> segment_median_map;
2943 map<CSCDetId, GlobalPoint> segment_position_map;
2953 LocalPoint localPos = (*dSiter).localPosition();
2957 globalPosition = cscchamber->
toGlobal(localPos);
2961 std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
2962 int nRH = (*dSiter).nRecHits();
2967 vector<float> non_zero;
2969 for (vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
2970 non_zero.push_back(iRH->tpeak());
2975 sort(non_zero.begin(), non_zero.end());
2976 int middle_index = non_zero.size() / 2;
2977 float average_two = (non_zero.at(middle_index - 1) + non_zero.at(middle_index)) / 2.;
2978 if (non_zero.size() % 2)
2979 average_two = non_zero.at(middle_index);
2982 segment_median_map[
id] = average_two;
2983 segment_position_map[
id] = globalPosition;
2985 double distToIP =
sqrt(globalPosition.
x() * globalPosition.
x() + globalPosition.
y() * globalPosition.
y() +
2986 globalPosition.
z() * globalPosition.
z());
2991 "Segment mean time",
3000 "timeChamberByType",
3001 "Segment mean time by chamber",
3011 "seg_time_vs_distToIP",
3012 "Segment time vs. Distance to IP",
3022 "seg_time_vs_globZ",
3023 "Segment time vs. z position",
3033 "seg_time_vs_absglobZ",
3034 "Segment time vs. abs(z position)",
3046 map<CSCDetId, float>::const_iterator it_outer;
3047 map<CSCDetId, float>::const_iterator it_inner;
3048 for (it_outer = segment_median_map.begin(); it_outer != segment_median_map.end(); it_outer++) {
3049 CSCDetId id_outer = it_outer->first;
3050 float t_outer = it_outer->second;
3053 for (it_inner = segment_median_map.begin(); it_inner != segment_median_map.end(); it_inner++) {
3054 CSCDetId id_inner = it_inner->first;
3055 float t_inner = it_inner->second;
3071 id_outer.
ring() == id_inner.
ring()) {
3073 "diff_opposite_endcaps",
3074 "#Delta t [ME+]-[ME-] for chambers in same station and ring",
3080 "diff_opposite_endcaps_byType",
3081 "#Delta t [ME+]-[ME-] for chambers in same station and ring",
3097 vector<L1MuGMTReadoutRecord> L1Mrec = pCollection->
getRecords();
3098 vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
3099 int L1GMT_BXN = -100;
3100 bool has_CSCTrigger =
false;
3101 bool has_beamHaloTrigger =
false;
3102 for (igmtrr = L1Mrec.begin(); igmtrr != L1Mrec.end(); igmtrr++) {
3103 std::vector<L1MuRegionalCand>::const_iterator iter1;
3104 std::vector<L1MuRegionalCand> rmc;
3107 rmc = igmtrr->getCSCCands();
3108 for (iter1 = rmc.begin(); iter1 != rmc.end(); iter1++) {
3109 if (!(*iter1).empty()) {
3111 int kQuality = (*iter1).quality();
3113 has_beamHaloTrigger =
true;
3116 if (igmtrr->getBxInEvent() == 0 && icsc > 0) {
3118 L1GMT_BXN = igmtrr->getBxNr();
3119 has_CSCTrigger =
true;
3120 }
else if (igmtrr->getBxInEvent() == 0) {
3122 L1GMT_BXN = igmtrr->getBxNr();
3131 map<CSCDetId, int> ALCT_KeyWG_map;
3134 const CSCDetId& idALCT = (*j).first;
3137 if ((*digiIt).isValid()) {
3139 histos->
fill1DHist((*digiIt).getBX(),
"ALCT_getBX",
"ALCT.getBX()", 11, -0.5, 10.5,
"TimeMonitoring");
3141 (*digiIt).getFullBX(),
"ALCT_getFullBX",
"ALCT.getFullBX()", 3601, -0.5, 3600.5,
"TimeMonitoring");
3143 if (ALCT_KeyWG_map.find(idALCT.
chamberId()) == ALCT_KeyWG_map.end()) {
3144 ALCT_KeyWG_map[idALCT.
chamberId()] = (*digiIt).getKeyWG();
3155 map<CSCDetId, int> CLCT_getFullBx_map;
3158 const CSCDetId& idCLCT = (*j).first;
3161 if ((*digiIt).isValid()) {
3163 histos->
fill1DHist((*digiIt).getBX(),
"CLCT_getBX",
"CLCT.getBX()", 11, -0.5, 10.5,
"TimeMonitoring");
3165 (*digiIt).getFullBX(),
"CLCT_getFullBX",
"CLCT.getFullBX()", 3601, -0.5, 3600.5,
"TimeMonitoring");
3167 if (CLCT_getFullBx_map.find(idCLCT.
chamberId()) == CLCT_getFullBx_map.end()) {
3168 CLCT_getFullBx_map[idCLCT.
chamberId()] = (*digiIt).getFullBX();
3178 int n_correlatedlcts = 0;
3182 if ((*digiIt).isValid()) {
3185 (*digiIt).getBX(),
"CorrelatedLCTS_getBX",
"CorrelatedLCT.getBX()", 11, -0.5, 10.5,
"TimeMonitoring");
3190 int nRecHits =
recHits->size();
3192 if (has_CSCTrigger) {
3193 histos->
fill1DHist(L1GMT_BXN,
"BX_L1CSCCand",
"BX of L1 CSC Cand", 4001, -0.5, 4000.5,
"TimeMonitoring");
3196 "n_ALCTs_v_BX_L1CSCCand",
3197 "Number of ALCTs vs. BX of L1 CSC Cand",
3207 "n_CLCTs_v_BX_L1CSCCand",
3208 "Number of CLCTs vs. BX of L1 CSC Cand",
3218 "n_CorrelatedLCTs_v_BX_L1CSCCand",
3219 "Number of CorrelatedLCTs vs. BX of L1 CSC Cand",
3229 "n_RecHits_v_BX_L1CSCCand",
3230 "Number of RecHits vs. BX of L1 CSC Cand",
3240 "n_Segments_v_BX_L1CSCCand",
3241 "Number of Segments vs. BX of L1 CSC Cand",
3250 if (has_CSCTrigger && has_beamHaloTrigger) {
3252 L1GMT_BXN,
"BX_L1CSCCand_w_beamHalo",
"BX of L1 CSC (w beamHalo bit)", 4001, -0.5, 4000.5,
"TimeMonitoring");
3255 "n_ALCTs_v_BX_L1CSCCand_w_beamHalo",
3256 "Number of ALCTs vs. BX of L1 CSC Cand (w beamHalo bit)",
3266 "n_CLCTs_v_BX_L1CSCCand_w_beamHalo",
3267 "Number of CLCTs vs. BX of L1 CSC Cand (w beamHalo bit)",
3277 "n_CorrelatedLCTs_v_BX_L1CSCCand_w_beamHalo",
3278 "Number of CorrelatedLCTs vs. BX of L1 CSC Cand (w beamHalo bit)",
3288 "n_RecHits_v_BX_L1CSCCand_w_beamHalo",
3289 "Number of RecHits vs. BX of L1 CSC Cand (w beamHalo bit)",
3299 "n_Segments_v_BX_L1CSCCand_w_beamHalo",
3300 "Number of Segments vs. BX of L1 CSC Cand (w beamHalo bit)",
3322 event.getByToken(
rd_token, rawdata);
3326 unsigned long dccBinCheckMask = 0x06080016;
3327 unsigned int examinerMask = 0x1FEBF3F6;
3328 unsigned int errorMask = 0x0;
3337 unsigned long length = fedData.
size();
3340 std::stringstream examiner_out, examiner_err;
3343 if (examinerMask & 0x40000)
3345 if (examinerMask & 0x8000)
3347 if (examinerMask & 0x0400)
3349 examiner->
setMask(examinerMask);
3350 const short unsigned int*
data = (
short unsigned int*)fedData.
data();
3356 goodEvent = !(examiner->
errors() & dccBinCheckMask);
3365 const std::vector<CSCDDUEventData>& dduData = dccData.
dduData();
3370 for (
unsigned int iDDU = 0; iDDU < dduData.size(); ++iDDU) {
3373 if (dduData[iDDU].trailer().errorstat() & errorMask) {
3374 LogTrace(
"CSCDCCUnpacker|CSCRawToDigi") <<
"DDU# " << iDDU <<
" has serious error - no digis unpacked! " 3375 << std::hex << dduData[iDDU].trailer().errorstat();
3380 const std::vector<CSCEventData>& cscData = dduData[iDDU].cscData();
3381 for (
unsigned int iCSC = 0; iCSC < cscData.size(); ++iCSC) {
3383 int vmecrate = cscData[iCSC].dmbHeader()->crateID();
3384 int dmb = cscData[iCSC].dmbHeader()->dmbID();
3392 if ((vmecrate >= 1) && (vmecrate <= 60) && (dmb >= 1) && (dmb <= 10) && (dmb != 6)) {
3393 layer = pcrate->
detId(vmecrate, dmb, icfeb, ilayer);
3395 LogTrace(
"CSCTimingAlignment|CSCDCCUnpacker|CSCRawToDigi") <<
" detID input out of range!!! ";
3396 LogTrace(
"CSCTimingAlignment|CSCDCCUnpacker|CSCRawToDigi")
3397 <<
" skipping chamber vme= " << vmecrate <<
" dmb= " << dmb;
3402 int nalct = cscData[iCSC].dmbHeader()->nalct();
3403 bool goodALCT =
false;
3405 if (nalct && cscData[iCSC].alctHeader()) {
3406 if (cscData[iCSC].alctHeader()->
check()) {
3412 int nclct = cscData[iCSC].dmbHeader()->nclct();
3413 bool goodTMB =
false;
3414 if (nclct && cscData[iCSC].tmbData()) {
3415 if (cscData[iCSC].tmbHeader()->
check()) {
3416 if (cscData[iCSC].comparatorData()->
check())
3421 if (goodTMB && goodALCT) {
3422 if (ALCT_KeyWG_map.find(
layer) == ALCT_KeyWG_map.end()) {
3423 printf(
"no ALCT info for Chamber %d %d %d %d \n",
3430 if (CLCT_getFullBx_map.find(
layer) == CLCT_getFullBx_map.end()) {
3431 printf(
"no CLCT info for Chamber %d %d %d %d \n",
3438 int ALCT0Key = ALCT_KeyWG_map.find(
layer)->second;
3439 int CLCTPretrigger = CLCT_getFullBx_map.find(
layer)->second;
3441 const CSCTMBHeader* tmbHead = cscData[iCSC].tmbHeader();
3452 "TMB_ALCTMatchTime",
3453 "TMB_ALCTMatchTime",
3461 tmbHead->
BXNCount(),
"TMB_BXNCount",
"TMB_BXNCount", 3601, -0.5, 3600.5,
"TimeMonitoring");
3463 tmbHead->
ALCTMatchTime(),
"TMB_ALCTMatchTime",
"TMB_ALCTMatchTime", 7, -0.5, 6.5,
"TimeMonitoring");
3466 "TMB_ALCTMatchTime",
3467 "TMB_ALCTMatchTime",
3476 "prof_TMB_ALCTMatchTime",
3477 "prof_TMB_ALCTMatchTime",
3486 "prof_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3487 "prof_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3496 "prf_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3497 "prf_TMB_ALCTMatchTime_v_ALCT0KeyWG",
3509 if (TMB_ALCT_rel_L1A > 3563)
3510 TMB_ALCT_rel_L1A = TMB_ALCT_rel_L1A - 3564;
3511 if (TMB_ALCT_rel_L1A < 0)
3512 TMB_ALCT_rel_L1A = TMB_ALCT_rel_L1A + 3564;
3516 TMB_ALCT_rel_L1A,
"h1D_TMB_ALCT_rel_L1A",
"h1D_TMB_ALCT_rel_L1A", 11, 144.5, 155.5,
"TimeMonitoring");
3519 "h2D_TMB_ALCT_rel_L1A",
3520 "h2D_TMB_ALCT_rel_L1A",
3530 "h2D_TMB_ALCT_rel_L1A_by_ring",
3531 "h2D_TMB_ALCT_rel_L1A_by_ring",
3541 "prof_TMB_ALCT_rel_L1A",
3542 "prof_TMB_ALCT_rel_L1A",
3551 "prof_TMB_ALCT_rel_L1A_by_ring",
3552 "prof_TMB_ALCT_rel_L1A_by_ring",
3562 "h2D_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3563 "h2D_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3573 "prof_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3574 "prof_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3583 "prf_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3584 "prf_TMB_ALCT_rel_L1A_v_ALCT0KeyWG",
3597 if (examiner !=
nullptr)
void crcCFEB(bool enable)
void fillProfileByType(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, float ymin, float ymax, std::string folder)
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Global3DPoint GlobalPoint
void fillProfile(float x, float y, std::string name, std::string title, int binsx, float xmin, float xmax, float ymin, float ymax, std::string folder)
size_t size() const
Lenght of the data buffer in bytes.
void crcALCT(bool enable)
void fill1DHist(float x, std::string name, std::string title, int bins, float xmin, float xmax, std::string folder)
constexpr std::array< uint8_t, layerIndexSize > layer
C::const_iterator const_iterator
constant access iterator type
const std::vector< CSCDDUEventData > & dduData() const
accessor to dduData
T const * product() const
int ringSerial(CSCDetId id)
void fill1DHistByType(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void fill1DHistByStation(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
CSCDetId detId(int vme, int dmb, int cfeb, int layer=0) const
void fill2DHist(float x, float y, std::string name, std::string title, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, std::string folder)
CSCDetId chamberId() const
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
int32_t check(const uint16_t *&buffer, int32_t length)
char data[epos_bytes_allocation]
int chamberSerial(CSCDetId id)
ExaminerStatusType errors(void) const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
edm::EDGetTokenT< FEDRawDataCollection > rd_token
void setMask(ExaminerMaskType mask)