39 eventHeaderCollection_(iConfig.getParameter<
std::
string>(
"eventHeaderCollection")),
40 eventHeaderProducer_(iConfig.getParameter<
std::
string>(
"eventHeaderProducer")),
41 digiCollection_(iConfig.getParameter<
std::
string>(
"digiCollection")),
42 digiProducer_(iConfig.getParameter<
std::
string>(
"digiProducer")),
43 digiPNCollection_(iConfig.getParameter<
std::
string>(
"digiPNCollection")),
48 _nsamples(iConfig.getUntrackedParameter<unsigned
int>(
"nSamples", 10)),
49 _presample(iConfig.getUntrackedParameter<unsigned
int>(
"nPresamples", 3)),
50 _firstsample(iConfig.getUntrackedParameter<unsigned
int>(
"firstSample", 1)),
51 _lastsample(iConfig.getUntrackedParameter<unsigned
int>(
"lastSample", 2)),
52 _samplemin(iConfig.getUntrackedParameter<unsigned
int>(
"sampleMin", 3)),
53 _samplemax(iConfig.getUntrackedParameter<unsigned
int>(
"sampleMax", 9)),
54 _nsamplesPN(iConfig.getUntrackedParameter<unsigned
int>(
"nSamplesPN", 50)),
55 _presamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"nPresamplesPN", 6)),
56 _firstsamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"firstSamplePN", 7)),
57 _lastsamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"lastSamplePN", 8)),
58 _niter(iConfig.getUntrackedParameter<unsigned
int>(
"nIter", 3)),
59 _chi2max(iConfig.getUntrackedParameter<double>(
"chi2Max", 10.0)),
60 _timeofmax(iConfig.getUntrackedParameter<double>(
"timeOfMax", 4.5)),
61 _ecalPart(iConfig.getUntrackedParameter<
std::
string>(
"ecalPart",
"EB")),
62 _fedid(iConfig.getUntrackedParameter<
int>(
"fedID", -999)),
63 resdir_(iConfig.getUntrackedParameter<
std::
string>(
"resDir")),
127 rootfile +=
"/TmpTreeTestPulseAnalyzer.root";
131 for (
unsigned int i = 0;
i <
nCrys;
i++) {
132 std::stringstream
name;
152 trees[
i]->SetBranchAddress(
"ieta", &
eta);
153 trees[
i]->SetBranchAddress(
"iphi", &
phi);
168 for (
unsigned int j = 0;
j <
nCrys;
j++) {
178 for (
unsigned int j = 0;
j <
nMod;
j++) {
185 std::stringstream namefile;
186 namefile <<
resdir_ <<
"/APDPN_TESTPULSE.root";
206 DCCHeader = pDCCHeader.
product();
250 int fed = headerItr->fedId();
255 runType = headerItr->getRunType();
256 runNum = headerItr->getRunNumber();
257 event = headerItr->getLV1();
259 dccID = headerItr->getDccInTCCCommand();
260 fedID = headerItr->fedId();
298 std::map<int, std::vector<double> > allPNAmpl;
299 std::map<int, std::vector<int> > allPNGain;
306 bool isMemRelevant =
false;
307 for (
unsigned int imem = 0; imem <
dccMEM.size(); imem++) {
309 isMemRelevant =
true;
317 for (
int samId = 0; samId < (*pnItr).size(); samId++) {
318 pn[samId] = (*pnItr).sample(samId).adc();
319 pnG[samId] = (*pnItr).sample(samId).gainId();
322 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"PN gain different from 1 for sample " << samId;
335 ypnrange[
k] =
pn[
k] - bl;
337 if (ypnrange[
k] > val_max) {
338 val_max = ypnrange[
k];
343 chi2pn = pnfit->
doFit(samplemax, &ypnrange[0]);
345 if (chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
372 EBDetId id_crystal(digiItr->id());
375 int etaG = id_crystal.ieta();
376 int phiG = id_crystal.iphi();
382 etaL = LocalCoord.first;
383 phiL = LocalCoord.second;
394 int xtal = elecid_crystal.
xtalId();
404 unsigned int MyPn0 = pnpair.first;
405 unsigned int MyPn1 = pnpair.second;
425 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
427 adc[
i] = samp_crystal.adc();
428 adcG[
i] = samp_crystal.gainId();
446 yrange[
k] =
adc[
k] - bl;
447 if (yrange[
k] > val_max) {
476 if (val_max > 100000. ||
chi2 < 0. ||
chi2 == 102) {
485 trees[channel]->Fill();
492 EEDetId id_crystal(digiItr->id());
495 phi = id_crystal.ix();
496 eta = id_crystal.iy();
498 int iX = (
phi - 1) / 5 + 1;
499 int iY = (
eta - 1) / 5 + 1;
520 unsigned int MyPn0 = pnpair.first;
521 unsigned int MyPn1 = pnpair.second;
550 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
552 adc[
i] = samp_crystal.adc();
553 adcG[
i] = samp_crystal.gainId();
572 yrange[
k] =
adc[
k] - bl;
573 if (yrange[
k] > val_max) {
583 if (allPNAmpl[
dccMEM[dccMEMIndex]].
size() > MyPn0)
587 if (allPNAmpl[
dccMEM[dccMEMIndex + 1]].
size() > MyPn1)
592 if (allPNGain[
dccMEM[dccMEMIndex]].
size() > MyPn0)
605 if (val_max > 100000. ||
chi2 < 0. ||
chi2 == 102) {
614 trees[channel]->Fill();
630 std::stringstream del;
632 system(del.str().c_str());
638 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
639 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"\t+=+ Analyzing test pulse data: getting APD, PN +=+";
647 restrees =
new TTree(
"TPAPD",
"TPAPD");
682 TMom* APDAnal[1700][10];
683 TMom* PNAnal[9][2][10];
685 for (
unsigned int iMod = 0; iMod <
nMod; iMod++) {
686 for (
unsigned int ich = 0; ich < 2; ich++) {
687 for (
unsigned int ig = 0; ig <
nGainPN; ig++) {
688 PNAnal[iMod][ich][ig] =
new TMom();
693 for (
unsigned int iCry = 0; iCry <
nCrys; iCry++) {
695 for (
unsigned int iG = 0; iG <
nGainAPD; iG++) {
696 APDAnal[iCry][iG] =
new TMom();
701 unsigned int iMod =
iModule[iCry] - 1;
707 Long64_t nbytes = 0, nb = 0;
708 for (Long64_t jentry = 0; jentry <
trees[iCry]->GetEntriesFast(); jentry++) {
709 nb =
trees[iCry]->GetEntry(jentry);
724 if (
trees[iCry]->GetEntries() < 10) {
726 for (
int j = 0;
j < 6;
j++) {
739 for (
unsigned int ig = 0; ig <
nGainAPD; ig++) {
742 APD[2] = APDAnal[iCry][ig]->
getM3();
756 for (
unsigned int ig = 0; ig <
nGainPN; ig++) {
757 for (
unsigned int iMod = 0; iMod <
nMod; iMod++) {
758 for (
int ch = 0; ch < 2; ch++) {
765 PN[1] = PNAnal[iMod][ch][ig]->
getRMS();
766 PN[2] = PNAnal[iMod][ch][ig]->
getM3();
768 PN[4] = PNAnal[iMod][ch][ig]->
getMin();
769 PN[5] = PNAnal[iMod][ch][ig]->
getMax();
782 std::stringstream del;
784 system(del.str().c_str());
792 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"\t+=+ ...................................... done +=+";
793 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
void addEntry(double val)
const unsigned int _niter
Log< level::Info, true > LogVerbatim
static XYCoord localCoord(int icr)
std::map< int, int > channelMapEE
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
static std::vector< ME::DCCid > memFromDcc(ME::DCCid idcc)
unsigned int iModule[1700]
const unsigned int _presamplePN
const unsigned int _samplemax
void analyze(const edm::Event &e, const edm::EventSetup &c) override
const std::string resdir_
const std::string digiProducer_
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
static int side(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
T const * product() const
std::vector< T >::const_iterator const_iterator
const edm::EDGetTokenT< EcalPnDiodeDigiCollection > pnDiodeDigiToken_
const unsigned int _nsamplesPN
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > mappingToken_
Log< level::Error, false > LogError
EcalTestPulseAnalyzer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< EBDigiCollection > ebDigiToken_
double fit_third_degree_polynomial(double *, double *)
static std::pair< int, int > pn(int ilmmod)
int hashedIndex(int ieta, int iphi)
static std::pair< int, int > pn(int dee, int ilmod)
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
int towerId() const
get the tower id
const std::string eventHeaderCollection_
const std::string _ecalPart
int channelId() const
so far for EndCap only :
#define DEFINE_FWK_MODULE(type)
const_iterator begin() const
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
unsigned int firstChanMod[9]
const_iterator end() const
~EcalTestPulseAnalyzer() override
const unsigned int _firstsample
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
const unsigned int _lastsample
int stripId() const
get the tower id
const std::string digiCollection_
const unsigned int _nsamples
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
int xtalId() const
get the channel id
edm::EDGetTokenT< EEDigiCollection > eeDigiToken_
std::vector< int > dccMEM
const unsigned int _lastsamplePN
double doFit(int, double *)
EcalLogicID towerID(EcalElectronicsId const &)
const edm::EDGetTokenT< EcalRawDataCollection > rawDataToken_
void set_params(int, int, int, int, int, double, double, int, int)
int iDCCId() const
get the DCCId
unsigned int isFirstChanModFilled[9]
const unsigned int _samplemin
const unsigned int _firstsamplePN
static std::vector< ME::LMMid > lmmodFromDcc(ME::DCCid idcc)
const unsigned int _presample