CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoTracker/MeasurementDet/plugins/TkMeasurementDetSet.cc

Go to the documentation of this file.
00001 #include "TkMeasurementDetSet.h"
00002 #include "TkStripMeasurementDet.h"
00003 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00004 
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 
00008 void StMeasurementDetSet::init(std::vector<TkStripMeasurementDet> & stripDets) {
00009   // assume vector is full and ordered!
00010   int size = stripDets.size();
00011   
00012   empty_.resize(size,true);
00013   activeThisEvent_.resize(size,true);
00014   activeThisPeriod_.resize(size,true);
00015   id_.resize(size);
00016   subId_.resize(size);
00017   totalStrips_.resize(size);
00018   
00019   bad128Strip_.resize(size*6);
00020   hasAny128StripBad_.resize(size);
00021   badStripBlocks_.resize(size);
00022 
00023   if (isRegional()) {
00024     clusterI_.resize(2*size);
00025   }  else {
00026     detSet_.resize(size);
00027   }
00028   
00029   for (int i=0; i!=size; ++i) {
00030     auto & mdet =  stripDets[i]; 
00031     mdet.setIndex(i);
00032     //intialize the detId !
00033     id_[i] = mdet.specificGeomDet().geographicalId().rawId();
00034     subId_[i]=SiStripDetId(id_[i]).subdetId()-3;
00035     //initalize the total number of strips
00036     totalStrips_[i] =  mdet.specificGeomDet().specificTopology().nstrips();
00037   }
00038 }
00039 
00040 
00041 void StMeasurementDetSet::set128StripStatus(int i, bool good, int idx) { 
00042     int offset =  nbad128*i;
00043     if (idx == -1) {
00044       std::fill(bad128Strip_.begin()+offset, bad128Strip_.begin()+offset+6, !good);
00045       hasAny128StripBad_[i] = !good;
00046     } else {
00047       bad128Strip_[offset+idx] = !good;
00048       if (good == false) {
00049         hasAny128StripBad_[i] = false;
00050       } else { // this should not happen, as usually you turn on all fibers
00051         // and then turn off the bad ones, and not vice-versa,
00052         // so I don't care if it's not optimized
00053         hasAny128StripBad_[i] = true;
00054         for (int j = 0; i < (totalStrips_[j] >> 7); j++) {
00055           if (bad128Strip_[j+offset] == false) hasAny128StripBad_[i] = false; break;
00056         }
00057       }    
00058     } 
00059   }
00060   
00061 
00062 void StMeasurementDetSet::initializeStripStatus(const SiStripQuality *quality, int qualityFlags, int qualityDebugFlags, edm::ParameterSet cutPset) {
00063   if (qualityFlags & BadStrips) {
00064      badStripCuts_[SiStripDetId::TIB-3] = BadStripCuts(cutPset.getParameter<edm::ParameterSet>("TIB"));
00065     badStripCuts_[SiStripDetId::TOB-3] = BadStripCuts(cutPset.getParameter<edm::ParameterSet>("TOB"));
00066     badStripCuts_[SiStripDetId::TID-3] = BadStripCuts(cutPset.getParameter<edm::ParameterSet>("TID"));
00067     badStripCuts_[SiStripDetId::TEC-3] = BadStripCuts(cutPset.getParameter<edm::ParameterSet>("TEC"));
00068   }
00069   setMaskBad128StripBlocks((qualityFlags & MaskBad128StripBlocks) != 0);
00070   
00071   
00072   if ((quality != 0) && (qualityFlags != 0))  {
00073     edm::LogInfo("MeasurementTracker") << "qualityFlags = " << qualityFlags;
00074     unsigned int on = 0, tot = 0; 
00075     unsigned int foff = 0, ftot = 0, aoff = 0, atot = 0; 
00076     for (int i=0; i!=nDet(); i++) {
00077       uint32_t detid = id(i);
00078       if (qualityFlags & BadModules) {
00079         bool isOn = quality->IsModuleUsable(detid);
00080         setActive(i,isOn);
00081         tot++; on += (unsigned int) isOn;
00082         if (qualityDebugFlags & BadModules) {
00083           edm::LogInfo("MeasurementTracker")<< "MeasurementTrackerImpl::initializeStripStatus : detid " << detid << " is " << (isOn ?  "on" : "off");
00084         }
00085       } else {
00086         setActive(i,true);
00087       }
00088       // first turn all APVs and fibers ON
00089       set128StripStatus(i,true); 
00090       if (qualityFlags & BadAPVFibers) {
00091         short badApvs   = quality->getBadApvs(detid);
00092         short badFibers = quality->getBadFibers(detid);
00093         for (int j = 0; j < 6; j++) {
00094           atot++;
00095           if (badApvs & (1 << j)) {
00096             set128StripStatus(i,false, j);
00097             aoff++;
00098           }
00099         }
00100         for (int j = 0; j < 3; j++) {
00101           ftot++;
00102              if (badFibers & (1 << j)) {
00103                set128StripStatus(i,false, 2*j);
00104                set128StripStatus(i,false, 2*j+1);
00105                foff++;
00106              }
00107         }
00108       } 
00109       auto & badStrips = getBadStripBlocks(i);
00110        badStrips.clear();
00111        if (qualityFlags & BadStrips) {
00112          SiStripBadStrip::Range range = quality->getRange(detid);
00113          for (SiStripBadStrip::ContainerIterator bit = range.first; bit != range.second; ++bit) {
00114            badStrips.push_back(quality->decode(*bit));
00115          }
00116        }
00117     }
00118     if (qualityDebugFlags & BadModules) {
00119       edm::LogInfo("MeasurementTracker StripModuleStatus") << 
00120         " Total modules: " << tot << ", active " << on <<", inactive " << (tot - on);
00121     }
00122     if (qualityDebugFlags & BadAPVFibers) {
00123       edm::LogInfo("MeasurementTracker StripAPVStatus") << 
00124         " Total APVs: " << atot << ", active " << (atot-aoff) <<", inactive " << (aoff);
00125         edm::LogInfo("MeasurementTracker StripFiberStatus") << 
00126           " Total Fibers: " << ftot << ", active " << (ftot-foff) <<", inactive " << (foff);
00127     }
00128   } else {
00129     for (int i=0; i!=nDet(); i++) {
00130       setActive(i,true);          // module ON
00131       set128StripStatus(i,true);  // all APVs and fibers ON
00132     }
00133   }
00134 }