Skip to content

Commit

Permalink
Merge pull request cms-sw#17692 from nancymarinelli/TP_PhaseII_V1
Browse files Browse the repository at this point in the history
Update the dataformat for the TP per crystal. It now follows what pre…
  • Loading branch information
cmsbuild authored Mar 13, 2017
2 parents e8cf191 + a0da5e5 commit bf3678e
Show file tree
Hide file tree
Showing 14 changed files with 301 additions and 260 deletions.
41 changes: 15 additions & 26 deletions DataFormats/EcalDigi/interface/EcalEBTriggerPrimitiveDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <ostream>
#include <vector>
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveSample.h"
#include "DataFormats/EcalDigi/interface/EcalEBTriggerPrimitiveSample.h"



/** \class EcalEBTriggerPrimitiveDigi
\author N. Marinelli - Univ. of Notre Dame
*/
Expand All @@ -31,36 +31,24 @@ class EcalEBTriggerPrimitiveDigi {
const EBDetId& id() const { return id_; }
int size() const { return size_; }

const EcalTriggerPrimitiveSample& operator[](int i) const { return data_[i]; }
const EcalTriggerPrimitiveSample& sample(int i) const { return data_[i]; }
const EcalEBTriggerPrimitiveSample& operator[](int i) const { return data_[i]; }
const EcalEBTriggerPrimitiveSample& sample(int i) const { return data_[i]; }

void setSize(int size);
void setSample(int i, const EcalTriggerPrimitiveSample& sam);
void setSample(int i, const EcalEBTriggerPrimitiveSample& sam);
void setSampleValue(int i, uint16_t value) { data_[i].setValue(value); }

static const int MAXSAMPLES = 20;

/// get the encoded/compressed Et of interesting sample
int compressedEt() const;


/// get the fine-grain bit of interesting sample
bool fineGrain() const;

/// get the Trigger tower Flag of interesting sample
int ttFlag() const;

/// Gets the "strip fine grain veto bit" (sFGVB) used as L1A spike detection
/// @return 0 spike like pattern
/// 1 EM shower like pattern
int sFGVB() const;

/// Gets the L1A spike detection flag. Beware the flag is inverted.
/// Deprecated, use instead sFGVB() method, whose name is less missleading
/// @return 0 spike like pattern
/// 1 EM shower like pattern
int l1aSpike() const { return sFGVB(); }
/// get the 10 bits Et of interesting sample
int encodedEt() const;

/// Spike flag
bool l1aSpike() const;

/// Time info
int time() const;

/// True if debug mode (# of samples > 1)
bool isDebug() const;

Expand All @@ -70,7 +58,8 @@ class EcalEBTriggerPrimitiveDigi {
private:
EBDetId id_;
int size_;
std::vector<EcalTriggerPrimitiveSample> data_;
std::vector<EcalEBTriggerPrimitiveSample> data_;

};


Expand Down
56 changes: 56 additions & 0 deletions DataFormats/EcalDigi/interface/EcalEBTriggerPrimitiveSample.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef ECALEBTRIGGERPRIMITIVESAMPLE_H
#define ECALEBTRIGGERPRIMITIVESAMPLE_H 1

#include <boost/cstdint.hpp>
#include <ostream>



/** \class EcalEBTriggerPrimitiveSample
\author N. Marinelli - Univ of Notre Dame
*/

class EcalEBTriggerPrimitiveSample {
public:
EcalEBTriggerPrimitiveSample();
EcalEBTriggerPrimitiveSample(uint16_t data);
EcalEBTriggerPrimitiveSample(int encodedEt);
EcalEBTriggerPrimitiveSample(int encodedEt, bool isASpike);
EcalEBTriggerPrimitiveSample(int encodedEt, bool isASpike, int timing);

///Set data
void setValue(uint16_t data){ theSample = data;}
// The sample is a 16 bit word defined as:
//
// o o o o o o o o o o o o o o o o
// |________| |____________________|
// ~60ps res spike Et
// time info flag
//


/// get the raw word
uint16_t raw() const { return theSample; }

/// get the encoded Et (10 bits)
int encodedEt() const { return theSample&0x3FF; }

bool l1aSpike() const { return (theSample&0x400)!=0; }

int time() const { return theSample>>11; }

/// for streaming
uint16_t operator()() { return theSample; }

private:
uint16_t theSample;

};

std::ostream& operator<<(std::ostream& s, const EcalEBTriggerPrimitiveSample& samp);




#endif
31 changes: 11 additions & 20 deletions DataFormats/EcalDigi/src/EcalEBTriggerPrimitiveDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ EcalEBTriggerPrimitiveDigi::EcalEBTriggerPrimitiveDigi(const EBDetId& id) : id_(
size_(0), data_(MAXSAMPLES) {
}

void EcalEBTriggerPrimitiveDigi::setSample(int i, const EcalTriggerPrimitiveSample& sam)
void EcalEBTriggerPrimitiveDigi::setSample(int i, const EcalEBTriggerPrimitiveSample& sam)
{
// std::cout << " In setSample i " << i << " sam " << sam << std::endl;
data_[i]=sam;
Expand All @@ -31,39 +31,30 @@ int EcalEBTriggerPrimitiveDigi::sampleOfInterest() const
}

/// get the encoded/compressed Et of interesting sample
int EcalEBTriggerPrimitiveDigi::compressedEt() const
int EcalEBTriggerPrimitiveDigi::encodedEt() const
{
int sample = sampleOfInterest();
if (sample != -1)
return data_[sample].compressedEt();
return data_[sample].encodedEt();
else
return -1;
}

/// get the fine-grain bit of interesting sample
bool EcalEBTriggerPrimitiveDigi::fineGrain() const
{
int sample = sampleOfInterest();
if (sample != -1)
return data_[sample].fineGrain();
else
return false;
}
/// get the Trigger tower Flag of interesting sample
int EcalEBTriggerPrimitiveDigi::ttFlag() const
{


bool EcalEBTriggerPrimitiveDigi::l1aSpike() const
{
int sample = sampleOfInterest();
if (sample != -1)
return data_[sample].ttFlag();
return data_[sample].l1aSpike();
else
return -1;
}
}

int EcalEBTriggerPrimitiveDigi::sFGVB() const
int EcalEBTriggerPrimitiveDigi::time() const
{
int sample = sampleOfInterest();
if (sample != -1)
return data_[sample].l1aSpike();
return data_[sample].time();
else
return -1;
}
Expand Down
29 changes: 29 additions & 0 deletions DataFormats/EcalDigi/src/EcalEBTriggerPrimitiveSample.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "DataFormats/EcalDigi/interface/EcalEBTriggerPrimitiveSample.h"



EcalEBTriggerPrimitiveSample::EcalEBTriggerPrimitiveSample() : theSample(0) { }
EcalEBTriggerPrimitiveSample::EcalEBTriggerPrimitiveSample(uint16_t data) : theSample(data) { }

EcalEBTriggerPrimitiveSample::EcalEBTriggerPrimitiveSample(int encodedEt, bool isASpike) {
theSample=(encodedEt&0x3FF)| ((isASpike)?(0x400):(0));
}


EcalEBTriggerPrimitiveSample::EcalEBTriggerPrimitiveSample(int encodedEt, bool isASpike, int timing) {
theSample=(encodedEt&0x3FF)| ((isASpike)?(0x400):(0)) | timing<<11;
}


EcalEBTriggerPrimitiveSample::EcalEBTriggerPrimitiveSample(int encodedEt) {
theSample=encodedEt&0x3FF;
}



std::ostream& operator<<(std::ostream& s, const EcalEBTriggerPrimitiveSample& samp) {
return s << "ET=" << samp.encodedEt() << ", isASpike=" << samp.l1aSpike()<< " timing= " << samp.time() ;

}


7 changes: 5 additions & 2 deletions DataFormats/EcalDigi/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
<class name="EcalTriggerPrimitiveSample" ClassVersion="10">
<version ClassVersion="10" checksum="251958438"/>
</class>
<class name="EcalEBTriggerPrimitiveSample" ClassVersion="13">
<version ClassVersion="13" checksum="4171161153"/>
</class>
<class name="EcalTriggerPrimitiveDigi" ClassVersion="12">
<version ClassVersion="12" checksum="3058718200"/>
</class>
<class name="EcalEBTriggerPrimitiveDigi" ClassVersion="11">
<version ClassVersion="11" checksum="3942030638"/>
<class name="EcalEBTriggerPrimitiveDigi" ClassVersion="14">
<version ClassVersion="14" checksum="3583827889"/>
</class>

<class name="EcalPseudoStripInputSample" ClassVersion="10">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef EcalEBTrigPrimTestAlgo_h
#define EcalEBTrigPrimTestAlgo_h
/** \class EcalEBTrigPrimTestAlgo
\author N. Marinelli - Univ. of Notre Dame
* forPhase II
* As of now we do not know yet how the electronics would look like
* so for now we build some machinery to produce TPs which are taken from the RecHits
* While the new digitization is not yet implemented, we use the old Digis to make TP per crystal
*
************************************************************/
#include <sys/time.h>
Expand Down Expand Up @@ -38,7 +38,7 @@

class EcalTrigTowerDetId;
class ETPCoherenceTest;
class EcalTriggerPrimitiveSample;
class EcalEBTriggerPrimitiveSample;
class CaloSubdetectorGeometry;
class EBDataFrame;

Expand Down Expand Up @@ -128,8 +128,8 @@ class EcalEBTrigPrimTestAlgo
std::vector<std::vector<std::pair<int,std::vector<EBDataFrame> > > > towerMapEB_;
std::vector<std::vector<std::pair<int,std::vector<EEDataFrame> > > > towerMapEE_;
std::vector<std::pair<int,EcalTrigTowerDetId> > hitTowers_;
std::vector<EcalTriggerPrimitiveSample> towtp_;
std::vector<EcalTriggerPrimitiveSample> towtp2_;
std::vector<EcalEBTriggerPrimitiveSample> towtp_;
std::vector<EcalEBTriggerPrimitiveSample> towtp2_;

enum {nbMaxStrips_=5};
enum {nbMaxXtals_=5};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef ECAL_FENIX_TCP_FORMAT_H
#define ECAL_FENIX_TCP_FORMAT_H

#include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveSample.h"
#include "DataFormats/EcalDigi/interface/EcalEBTriggerPrimitiveSample.h"
#include <vector>

class EcalTPGLutGroup ;
Expand All @@ -26,7 +26,7 @@ class EcalFenixTcpFormat {
virtual ~EcalFenixTcpFormat();

void process(std::vector<int>&,std::vector<int>&);
void process(std::vector<int> &Et, std::vector<int> &fgvb, std::vector<int> &sfgvb, int eTTotShift, std::vector<EcalTriggerPrimitiveSample> & out, std::vector<EcalTriggerPrimitiveSample> & outTcc, bool isInInnerRings) ;
void process(std::vector<int> &Et, std::vector<int> &fgvb, std::vector<int> &sfgvb, int eTTotShift, std::vector<EcalEBTriggerPrimitiveSample> & out, std::vector<EcalEBTriggerPrimitiveSample> & outTcc, bool isInInnerRings) ;
void setParameters(uint32_t towid,const EcalTPGLutGroup *ecaltpgLutGroup,const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike * ecaltpgSpike);

private:
Expand Down
84 changes: 4 additions & 80 deletions SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalEBTrigPrimTestAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,81 +101,6 @@ EcalEBTrigPrimTestAlgo::~EcalEBTrigPrimTestAlgo()
delete fenixTcpFormat_;
}

/*
void EcalEBTrigPrimTestAlgo::run(const edm::EventSetup & setup, EcalRecHitCollection const * rh,
EcalEBTrigPrimDigiCollection & result,
EcalEBTrigPrimDigiCollection & resultTcp)
{
//std::cout << " EcalEBTrigPrimTestAlgo: Testing that the algorythm is well plugged " << std::endl;
//std::cout << " EcalEBTrigPrimTestAlgo: recHit size " << rh->size() << std::endl;
edm::ESHandle<CaloSubdetectorGeometry> theBarrelGeometry_handle;
setup.get<EcalBarrelGeometryRecord>().get("EcalBarrel",theBarrelGeometry_handle);
const CaloSubdetectorGeometry *theBarrelGeometry;
theBarrelGeometry = &(*theBarrelGeometry_handle);
EcalEBTriggerPrimitiveDigi tp;
std::vector<EcalTriggerPrimitiveSample> tpSam[10];
uint16_t fEt;
double EtSat=128.;
for (unsigned int i=0;i<rh->size();i++) {
const EBDetId & myid1=(*rh)[i].id();
if ( (*rh)[i].energy() < 0.2 ) continue;
tp= EcalEBTriggerPrimitiveDigi( myid1);
tp.setSize(nSamples_);
int nSam=0;
for (int iSample=0; iSample<nSamples_; iSample++) {
if (debug_) std::cout << " DetId " << myid1 << "Subdetector " << myid1.subdet() << " ieta " << myid1.ieta() << " iphi " << myid1.iphi() << std::endl;
float theta = theBarrelGeometry->getGeometry(myid1)->getPosition().theta();
//uint16_t et=((*rh)[i].energy())*sin(theta);
double et=((*rh)[i].energy())*sin(theta);
double lsb10bits = 0. ;
int tpgADC10b = 0.;
lsb10bits = EtSat/1024. ;
if (lsb10bits>0)
tpgADC10b = int(et/lsb10bits+0.5) ;
if (debug_) std::cout << " Et in GeV " << et << " tpgADC10b " << tpgADC10b << std::endl;
fEt=et;
// if (fEt >0xfff)
// fEt=0xfff;
//fEt >>=2;
//if (fEt>0x3ff) fEt=0x3ff;
//std::cout << " Et after formatting " << fEt << std::endl;
EcalTriggerPrimitiveSample mysam(fEt);
tp.setSample(nSam, mysam );
nSam++;
if (debug_) std::cout << "in TestAlgo" <<" tp size "<<tp.size() << std::endl;
}
if (!tcpFormat_)
result.push_back(tp);
else
resultTcp.push_back(tp);
if (debug_) std::cout << " result size " << result.size() << std::endl;
}
}
*/


void EcalEBTrigPrimTestAlgo::run(const edm::EventSetup & setup,
EBDigiCollection const * digi,
Expand Down Expand Up @@ -296,16 +221,15 @@ void EcalEBTrigPrimTestAlgo::run(const edm::EventSetup & setup,
// call final tcp formatter
this->getFormatter()->setParameters( thisTower.rawId(),ecaltpgLutGroup_,ecaltpgLut_,ecaltpgBadTT_,ecaltpgSpike_);
this->getFormatter()->process(format_out_,tcpformat_out_);

// loop over the time samples and fill the TP
int nSam=0;
for (int iSample=firstSample;iSample<=lastSample;++iSample) {
etInADC= tcpformat_out_[iSample];
if (debug_) std::cout << " format_out " << tcpformat_out_[iSample] << " etInADC " << etInADC << std::endl;
// EcalTriggerPrimitiveSample mysam(etInADC);
//tp.setSample(nSam, mysam );

tp.setSample(nSam, EcalTriggerPrimitiveSample(etInADC, false, 0) );
bool isASpike=0; // no spikes for now
int timing=0; // set to 0 value for now
tp.setSample(nSam, EcalEBTriggerPrimitiveSample(etInADC,isASpike,timing) );

nSam++;
if (debug_) std::cout << "in TestAlgo" <<" tp size "<<tp.size() << std::endl;
Expand Down Expand Up @@ -368,7 +292,7 @@ void EcalEBTrigPrimTestAlgo::run(const edm::EventSetup & setup,
for (int iSample=0; iSample<myFrame.size(); iSample++) {
etInADC= myFrame.sample(iSample).adc();
EcalTriggerPrimitiveSample mysam(etInADC);
EcalEBTriggerPrimitiveSample mysam(etInADC);
tp.setSample(nSam, mysam );
nSam++;
if (debug_) std::cout << "in TestAlgo" <<" tp size "<<tp.size() << std::endl;
Expand Down
Loading

0 comments on commit bf3678e

Please sign in to comment.