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;
135 trees[
i] =
new TTree(name.str().c_str(), name.str().c_str());
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;
332 bl = dsum / ((double)_presamplePN);
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)
351 allPNGain[pnDetId.
iDCCId()].push_back(pngain);
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();
398 int iMod = module - 1;
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();
437 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
439 if (k < _presample - 1)
443 bl = dsum / ((double)_presample);
445 for (val_max = 0., k = 0; k <
_nsamples; k++) {
446 yrange[
k] =
adc[
k] - bl;
447 if (yrange[k] > val_max) {
477 if (val_max > 100000. || chi2 < 0. || chi2 == 102) {
486 trees[channel]->Fill();
493 EEDetId id_crystal(digiItr->id());
496 phi = id_crystal.ix();
497 eta = id_crystal.iy();
499 int iX = (
phi - 1) / 5 + 1;
500 int iY = (
eta - 1) / 5 + 1;
512 if (module >= 18 &&
side == 1)
514 int iMod = module - 1;
521 unsigned int MyPn0 = pnpair.first;
522 unsigned int MyPn1 = pnpair.second;
551 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
553 adc[
i] = samp_crystal.adc();
554 adcG[
i] = samp_crystal.gainId();
564 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
566 if (k < _presample - 1)
570 bl = dsum / ((double)_presample);
572 for (val_max = 0., k = 0; k <
_nsamples; k++) {
573 yrange[
k] =
adc[
k] - bl;
574 if (yrange[k] > val_max) {
585 if (allPNAmpl[
dccMEM[dccMEMIndex]].
size() > MyPn0)
589 if (allPNAmpl[
dccMEM[dccMEMIndex + 1]].
size() > MyPn1)
594 if (allPNGain[
dccMEM[dccMEMIndex]].
size() > MyPn0)
607 if (val_max > 100000. || chi2 < 0. || chi2 == 102) {
616 trees[channel]->Fill();
632 std::stringstream del;
634 system(del.str().c_str());
640 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
641 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"\t+=+ Analyzing test pulse data: getting APD, PN +=+";
649 restrees =
new TTree(
"TPAPD",
"TPAPD");
652 restrees->Branch(
"iphi", &
iphi,
"iphi/I");
653 restrees->Branch(
"ieta", &
ieta,
"ieta/I");
654 restrees->Branch(
"dccID", &
dccID,
"dccID/I");
655 restrees->Branch(
"side", &
side,
"side/I");
656 restrees->Branch(
"towerID", &
towerID,
"towerID/I");
657 restrees->Branch(
"channelID", &
channelID,
"channelID/I");
658 restrees->Branch(
"moduleID", &
moduleID,
"moduleID/I");
659 restrees->Branch(
"flag", &
flag,
"flag/I");
660 restrees->Branch(
"gain", &
gain,
"gain/I");
661 restrees->Branch(
"APD", &
APD,
"APD[6]/D");
668 restrees->SetBranchAddress(
"iphi", &
iphi);
669 restrees->SetBranchAddress(
"ieta", &
ieta);
670 restrees->SetBranchAddress(
"dccID", &
dccID);
671 restrees->SetBranchAddress(
"side", &
side);
672 restrees->SetBranchAddress(
"towerID", &
towerID);
673 restrees->SetBranchAddress(
"channelID", &
channelID);
674 restrees->SetBranchAddress(
"moduleID", &
moduleID);
675 restrees->SetBranchAddress(
"flag", &
flag);
676 restrees->SetBranchAddress(
"gain", &
gain);
677 restrees->SetBranchAddress(
"APD",
APD);
684 TMom* APDAnal[1700][10];
685 TMom* PNAnal[9][2][10];
687 for (
unsigned int iMod = 0; iMod <
nMod; iMod++) {
688 for (
unsigned int ich = 0; ich < 2; ich++) {
689 for (
unsigned int ig = 0; ig <
nGainPN; ig++) {
690 PNAnal[iMod][ich][ig] =
new TMom();
695 for (
unsigned int iCry = 0; iCry <
nCrys; iCry++) {
697 for (
unsigned int iG = 0; iG <
nGainAPD; iG++) {
698 APDAnal[iCry][iG] =
new TMom();
703 unsigned int iMod =
iModule[iCry] - 1;
709 Long64_t nbytes = 0, nb = 0;
710 for (Long64_t jentry = 0; jentry <
trees[iCry]->GetEntriesFast(); jentry++) {
711 nb =
trees[iCry]->GetEntry(jentry);
726 if (
trees[iCry]->GetEntries() < 10) {
728 for (
int j = 0;
j < 6;
j++) {
741 for (
unsigned int ig = 0; ig <
nGainAPD; ig++) {
744 APD[2] = APDAnal[iCry][ig]->
getM3();
758 for (
unsigned int ig = 0; ig <
nGainPN; ig++) {
759 for (
unsigned int iMod = 0; iMod <
nMod; iMod++) {
760 for (
int ch = 0; ch < 2; ch++) {
767 PN[1] = PNAnal[iMod][ch][ig]->
getRMS();
768 PN[2] = PNAnal[iMod][ch][ig]->
getM3();
770 PN[4] = PNAnal[iMod][ch][ig]->
getMin();
771 PN[5] = PNAnal[iMod][ch][ig]->
getMax();
784 std::stringstream del;
786 system(del.str().c_str());
794 edm::LogVerbatim(
"EcalTestPulseAnalyzer") <<
"\t+=+ ...................................... done +=+";
795 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)
const edm::EventSetup & c
int xtalId() const
get the channel id
unsigned int iModule[1700]
const unsigned int _presamplePN
const unsigned int _samplemax
void analyze(const edm::Event &e, const edm::EventSetup &c) override
std::vector< int > modules
int stripId() const
get the tower id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string resdir_
const std::string digiProducer_
#define DEFINE_FWK_MODULE(type)
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)
std::vector< T >::const_iterator const_iterator
const edm::EDGetTokenT< EcalPnDiodeDigiCollection > pnDiodeDigiToken_
const unsigned int _nsamplesPN
int towerId() const
get the tower id
const_iterator begin() const
The iterator returned can not safely be used across threads.
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)
bool getData(T &iHolder) const
int hashedIndex(int ieta, int iphi)
static std::pair< int, int > pn(int dee, int ilmod)
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
const std::string eventHeaderCollection_
const std::string _ecalPart
int iDCCId() const
get the DCCId
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
T const * product() const
const std::string digiCollection_
const unsigned int _nsamples
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const_iterator end() const
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)
unsigned int isFirstChanModFilled[9]
const unsigned int _samplemin
const unsigned int _firstsamplePN
static std::vector< ME::LMMid > lmmodFromDcc(ME::DCCid idcc)
tuple size
Write out results.
int channelId() const
so far for EndCap only :
const unsigned int _presample
const_iterator begin() const