87 float ZSthreshold = 0.608;
88 float zeroBinSize = ZSthreshold / 20.;
89 for(
int i=0;
i<20;
i++)
ybins[
i] =
i*zeroBinSize;
90 for(
int i=20;
i<89;
i++)
ybins[
i] = ZSthreshold * (
i-19);
116 for(
int ietindex = 0; ietindex < 34; ietindex++ ) {
117 for(
int iptindex = 0; iptindex < 72; iptindex++ ) {
137 std::vector<double> wsFromDB;
140 int nws = dccs.size();
142 for(std::vector<float>::const_iterator it = dccs[0].
begin(); it != dccs[0].end(); it++) {
143 wsFromDB.push_back(*it);
146 else edm::LogWarning(
"EBSelectiveReadoutTask") <<
"DCC weight set is not exactly 1.";
213 name =
"EBSRT tower event size";
214 EBTowerSize_ =
dqmStore_->
bookProfile2D(name, name, 72, 0, 72, 34, -17, 17, 100, 0, 200,
"s");
218 name =
"EBSRT TT flag mismatch";
223 name =
"EBSRT DCC event size";
226 for (
int i = 0;
i < 36;
i++) {
230 name =
"EBSRT event size vs DCC";
233 for (
int i = 0;
i < 36;
i++) {
237 name =
"EBSRT readout unit with SR forced";
243 name =
"EBSRT full readout SR Flags";
249 name =
"EBSRT full readout SR Flags Number";
253 name =
"EBSRT zero suppression 1 SR Flags";
259 name =
"EBSRT high interest TT Flags";
265 name =
"EBSRT medium interest TT Flags";
271 name =
"EBSRT low interest TT Flags";
277 name =
"EBSRT TT Flags";
281 name =
"EBSRT ZS Flagged Fully Readout";
287 name =
"EBSRT ZS Flagged Fully Readout Number";
291 name =
"EBSRT FR Flagged Dropped Readout";
297 name =
"EBSRT FR Flagged Dropped Readout Number";
301 name =
"EBSRT event size";
305 name =
"EBSRT high interest payload";
309 name =
"EBSRT low interest payload";
313 name =
"EBSRT high interest ZS filter output";
317 name =
"EBSRT low interest ZS filter output";
327 if ( !
init_ )
return;
419 for (
int iDcc = 0; iDcc <
nEBDcc; ++iDcc ) {
427 edm::LogWarning(
"EBSelectiveReadoutTask") <<
"FEDRawDataCollection not available";
431 int nFRO, nCompleteZS, nDroppedFRO;
439 double aLowInterest=0;
440 double aHighInterest=0;
441 double aAnyInterest=0;
453 for (
unsigned int digis=0; digis<ebDigis->size(); ++digis){
458 uint16_t statusCode = 0;
463 anaDigi(ebdf, *ebSrFlags, statusCode);
479 for(
int ietindex = 0; ietindex < 34; ietindex++ ) {
480 for(
int iptindex = 0; iptindex < 72; iptindex++ ) {
482 float xiet = (ietindex < 17) ? ietindex + 0.5 : (16-ietindex) + 0.5;
483 float xipt = iptindex + 0.5;
491 edm::LogWarning(
"EBSelectiveReadoutTask") <<
"EBDigiCollection not available";
495 std::map< int, std::vector<short> > towersStatus;
502 towersStatus.insert(std::make_pair(ism, dcchItr->getFEStatus()));
513 int ietindex = (iet>0) ? iet - 1 : 16 +
std::abs(iet);
516 int ipt =
id.iphi() + 2;
517 if ( ipt > 72 ) ipt = ipt - 72;
518 int iptindex = ipt - 1;
524 int flag = it->value() & ~
EcalSrFlag::SRF_FORCED_MASK;
527 if( towersStatus[ism].
size() > 0 ) status = (towersStatus[
ism])[itt];
532 if(
nPerRu_[ism-1][itt-1] == 0) {
552 edm::LogWarning(
"EBSelectiveReadoutTask") <<
"EBSRFlagCollection not available";
555 for(
int ietindex = 0; ietindex < 34; ietindex++ ) {
556 for(
int iptindex = 0; iptindex < 72; iptindex++ ) {
560 float xiet = (ietindex < 17) ? ietindex + 0.5 : (16-ietindex) + 0.5;
561 float xipt = iptindex + 0.5;
568 int binet=0, binpt=0;
571 binpt = h2d->GetXaxis()->FindBin(xipt);
572 binet = h2d->GetYaxis()->FindBin(xiet);
585 binpt = h2d->GetXaxis()->FindBin(xipt);
586 binet = h2d->GetYaxis()->FindBin(xiet);
599 binpt = h2d->GetXaxis()->FindBin(xipt);
600 binet = h2d->GetYaxis()->FindBin(xiet);
613 binpt = h2d->GetXaxis()->FindBin(xipt);
614 binet = h2d->GetYaxis()->FindBin(xiet);
628 binpt = h2d->GetXaxis()->FindBin(xipt);
629 binet = h2d->GetYaxis()->FindBin(xiet);
649 for (TPdigi = TPCollection->begin(); TPdigi != TPCollection->end(); ++TPdigi ) {
653 int iet = TPdigi->id().ieta();
654 int ietindex = (iet>0) ? iet - 1 : 16 +
std::abs(iet);
657 int ipt = TPdigi->id().iphi() + 2;
658 if ( ipt > 72 ) ipt = ipt - 72;
659 int iptindex = ipt - 1;
663 if ( (TPdigi->ttFlag() & 0x3) == 0 )
nEvtLowInterest[iptindex][ietindex]++;
667 if ( (TPdigi->ttFlag() & 0x3) == 3 )
nEvtHighInterest[iptindex][ietindex]++;
671 float xiet = (ietindex < 17) ? ietindex + 0.5 : (16-ietindex) + 0.5;
672 float xipt = iptindex + 0.5;
674 if ( ((TPdigi->ttFlag() & 0x3) == 1 || (TPdigi->ttFlag() & 0x3) == 3)
679 edm::LogWarning(
"EBSelectiveReadoutTask") <<
"EcalTrigPrimDigiCollection not available";
682 for(
int ietindex = 0; ietindex < 34; ietindex++ ) {
683 for(
int iptindex = 0; iptindex < 72; iptindex++ ) {
687 float xiet = (ietindex < 17) ? ietindex + 0.5 : (16-ietindex) + 0.5;
688 float xipt = iptindex + 0.5;
695 int binet=0, binpt=0;
698 binpt = h2d->GetXaxis()->FindBin(xipt);
699 binet = h2d->GetYaxis()->FindBin(xiet);
712 binpt = h2d->GetXaxis()->FindBin(xipt);
713 binet = h2d->GetYaxis()->FindBin(xiet);
726 binpt = h2d->GetXaxis()->FindBin(xipt);
727 binet = h2d->GetYaxis()->FindBin(xiet);
750 int ieta =
id.ieta();
751 int iphi =
id.iphi();
761 int iet = towid.
ieta();
762 int ietindex = (iet>0) ? iet - 1 : 16 +
std::abs(iet);
765 int ipt = towid.
iphi() + 2;
766 if ( ipt > 72 ) ipt = ipt - 72;
767 int iptindex = ipt - 1;
776 if(srf == srFlagColl.
end()){
780 bool highInterest = ((srf->value() & ~
EcalSrFlag::SRF_FORCED_MASK)
809 for(
int idcc=0; idcc<
nECALDcc; idcc++) {
810 for(
int isc=0; isc<
nDccChs; isc++) {
815 for(
int ietindex = 0; ietindex < 34; ietindex++ ) {
816 for(
int iptindex = 0; iptindex < 72; iptindex++ ) {
825 return xtalId.
tower();
833 throw cms::Exception(
"EBSelectiveReadoutTask") <<
"Crystal does not belong to ECAL";
841 throw cms::Exception(
"EBSelectiveReadoutTask") <<
"Not ECAL barrel.";
849 double ruHeaderPayload = 0.;
850 const int nEEDcc = 18;
851 const int firstEbDcc0 = nEEDcc/2;
852 for (
int iDcc0 = firstEbDcc0; iDcc0 < firstEbDcc0 +
nEBDcc; ++iDcc0 ) {
872 return 9+18*iEtaSM+iPhiSM;
879 const std::vector<int>& firWeights,
882 const int nFIRTaps = 6;
884 const std::vector<int>&
w = firWeights;
888 bool gain12saturated =
false;
889 const int gain12 = 0x01;
892 for(
int i = -1;
i < nFIRTaps - 1; ++
i, ++iWeight){
893 int iSample(
i + firstFIRSample);
894 if(iSample>=0 && iSample < frame.
size()){
896 if(sample.
gainId()!=gain12) gain12saturated =
true;
897 LogTrace(
"DccFir") << (iSample>=firstFIRSample?
"+":
"") << sample.
adc()
898 <<
"*(" << w[iWeight] <<
")";
899 acc+=sample.
adc()*w[iWeight];
902 ": Not enough samples in data frame or 'ecalDccZs1stSample' module "
903 "parameter is not valid...";
910 acc = (acc>=0)?(acc >> 8):-(-acc >> 8);
915 LogTrace(
"DccFir") <<
"acc: " << acc <<
"\n"
916 <<
"saturated: " << (gain12saturated?
"yes":
"no") <<
"\n";
919 *saturated = gain12saturated;
928 const int nFIRTaps = 6;
929 std::vector<int> firWeights(nFIRTaps, 0);
930 const static int maxWeight = 0xEFF;
931 for(
unsigned i=0;
i <
std::min((
size_t)nFIRTaps,normalizedWeights.size()); ++
i){
932 firWeights[
i] = lround(normalizedWeights[
i] * (1<<10));
934 firWeights[
i] = firWeights[
i]<0?-maxWeight:maxWeight;
942 bool notNormalized =
false;
944 for(
unsigned i=0;
i < weightsForZsFIR.size(); ++
i){
945 if(weightsForZsFIR[
i] > 1.) notNormalized =
true;
946 if((
int)weightsForZsFIR[
i]!=weightsForZsFIR[
i]) notInt =
true;
948 if(notInt && notNormalized){
950 <<
"weigtsForZsFIR paramater values are not valid: they "
951 <<
"must either be integer and uses the hardware representation "
952 <<
"of the weights or less or equal than 1 and used the normalized "
953 <<
"representation.";
957 firWeights_ = std::vector<int>(weightsForZsFIR.size());
958 for(
unsigned i = 0;
i< weightsForZsFIR.size(); ++
i){
965 log <<
"Input weights for FIR: ";
966 for(
unsigned i = 0;
i < weightsForZsFIR.size(); ++
i){
967 log << weightsForZsFIR[
i] <<
"\t";
971 log <<
"\nActual FIR weights: ";
974 s2 += firWeights_[
i]*firWeights_[
i];
978 log <<
"\nNormalized FIR weights after hw representation rounding: ";
int nEvtLowInterest[72][34]
To store the events with low interest TT.
MonitorElement * EBTTFlags_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int nCryTower[72][34]
To store the readout crystals / tower.
MonitorElement * EBMediumInterestTriggerTowerFlagMap_
static const int bytesPerCrystal
Number of bytes per crystal.
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * EBCompleteZSMap_
static std::vector< int > getFIRWeights(const std::vector< double > &normalizedWeights)
MonitorElement * EBTTFMismatch_
MonitorElement * EBDccEventSizeMap_
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
void rmdir(const std::string &fullpath)
MonitorElement * EBLowInterestZsFIR_
static const int ebTtEdge
Number of crystals along an EB TT.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const self & getMap() const
Some "id" conversions.
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcalTrigPrimDigiCollection_
MonitorElement * EBFullReadoutSRFlagCount_
static std::string sEB(const unsigned ism)
static const int SRF_FORCED_MASK
double getDccOverhead(subdet_t subdet) const
int nEvtHighInterest[72][34]
To store the events with high interest TT.
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::vector< std::vector< float > > dccNormalizedWeights_
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void configFirWeights(const std::vector< double > &weightsForZsFIR)
MonitorElement * EBDroppedFRMap_
EcalTrigTowerDetId readOutUnitOf(const EBDetId &xtalId) const
int gainId() const
get the gainId (2 bits)
int nEvtZSReadout[72][34]
To store the events with ZS1 or ZS2 readout.
int ieta() const
get the tower ieta
int iPhi2cIndex(int iPhi) const
MonitorElement * EBFullReadoutSRFlagMap_
int nEvtAnyInterest[72][34]
To store the events with any interest.
int iphi() const
get the crystal iphi
edm::EDGetTokenT< EBDigiCollection > EBDigiCollection_
MonitorElement * EBLowInterestPayload_
void cleanup(void)
Cleanup.
virtual ~EBSelectiveReadoutTask()
Destructor.
int nEvtFullReadout[72][34]
To store the events with full readout.
static int dccZsFIR(const EcalDataFrame &frame, const std::vector< int > &firWeights, int firstFIRSample, bool *saturated=0)
int nEvtZS1Readout[72][34]
To store the events with ZS1 readout.
MonitorElement * EBDccEventSize_
int nEvtDroppedReadoutIfFR[72][34]
To store the events with 0 channels readout when FR is requested.
uint16_t getStatusCode() const
const T & max(const T &a, const T &b)
MonitorElement * EBCompleteZSCount_
void removeElement(const std::string &name)
MonitorElement * EBHighInterestPayload_
std::vector< int > firWeights_
static const int SRF_FULL
Abs< T >::type abs(const T &t)
static const int nECALDcc
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
const EcalSRSettings * settings_
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
int ieta() const
get the crystal ieta
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void beginJob(void)
BeginJob.
double getEbEventSize(double nReadXtals) const
int dccPhiIndexOfRU(int i, int j) const
int nEvtCompleteReadoutIfZS[72][34]
To store the events with complete readout when ZS is requested.
edm::EDGetTokenT< EBSrFlagCollection > EBSRFlagCollection_
const_iterator end() const
MonitorElement * EBHighInterestTriggerTowerFlagMap_
int iphi() const
get the tower iphi
EBSelectiveReadoutTask(const edm::ParameterSet &ps)
Constructor.
int nEvtRUForced[72][34]
To store the events with RU forced.
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
int nEvtMediumInterest[72][34]
To store the events with medium interest TT.
int dccIndex(int i, int j) const
std::vector< Item >::const_iterator const_iterator
static const int nDccChs
maximum number of RUs read by a DCC
T const * product() const
bool ebRuActive_[nEbEta/ebTtEdge][nEbPhi/ebTtEdge]
int nPerRu_[nECALDcc][nDccChs]
MonitorElement * EBLowInterestTriggerTowerFlagMap_
MonitorElement * EBHighInterestZsFIR_
unsigned dccNum(const DetId &xtalId) const
iterator find(key_type k)
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
MonitorElement * EBZeroSuppression1SRFlagMap_
const_iterator find(uint32_t rawId) const
MonitorElement * EBDroppedFRCount_
int nEvtAnyReadout[72][34]
To store the events with any readout.
const_iterator end() const
MonitorElement * EBReadoutUnitForcedBitMap_
static EcalSubdetector subDet(const EBDetId &id)
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
MonitorElement * EBEventSize_
Detector det() const
get the detector field from this detid
int ism(int ieta, int iphi)
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
int iEta2cIndex(int iEta) const
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
edm::EDGetTokenT< FEDRawDataCollection > FEDRawDataCollection_
void anaDigi(const EBDataFrame &frame, const EBSrFlagCollection &srFlagColl, uint16_t statusCode)
MonitorElement * EBTowerSize_
static unsigned iTT(const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2)
int adc() const
get the ADC sample (12 bits)
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")