42 _presample(iConfig.getUntrackedParameter<double>(
"nPresamples", 6.7)),
43 _nsamplesaftmax(iConfig.getUntrackedParameter<unsigned
int>(
"nSamplesAftMax", 80)),
44 _noiseCut(iConfig.getUntrackedParameter<unsigned
int>(
"noiseCut", 7)),
45 _parabnbefmax(iConfig.getUntrackedParameter<unsigned
int>(
"paraBeforeMax", 8)),
46 _parabnaftmax(iConfig.getUntrackedParameter<unsigned
int>(
"paraAfterMax", 7)),
47 _thres(iConfig.getUntrackedParameter<unsigned
int>(
"threshold", 10)),
48 _lowlev(iConfig.getUntrackedParameter<unsigned
int>(
"lowLevel", 20)),
49 _highlev(iConfig.getUntrackedParameter<unsigned
int>(
"highLevel", 80)),
50 _nevlasers(iConfig.getUntrackedParameter<unsigned
int>(
"nEventLaser", 600)),
51 _timebefmax(iConfig.getUntrackedParameter<unsigned
int>(
"timeBefMax", 100)),
52 _timeaftmax(iConfig.getUntrackedParameter<unsigned
int>(
"timeAftMax", 250)),
53 _cutwindow(iConfig.getUntrackedParameter<double>(
"cutWindow", 0.1)),
54 _nsamplesshape(iConfig.getUntrackedParameter<unsigned
int>(
"nSamplesShape", 250)),
55 _presampleshape(iConfig.getUntrackedParameter<unsigned
int>(
"nPresamplesShape", 50)),
56 _slide(iConfig.getUntrackedParameter<unsigned
int>(
"nSlide", 100)),
57 _fedid(iConfig.getUntrackedParameter<
int>(
"fedID", -999)),
58 _debug(iConfig.getUntrackedParameter<
int>(
"debug", 0)),
59 resdir_(iConfig.getUntrackedParameter<
std::
string>(
"resDir")),
60 digiCollection_(iConfig.getParameter<
std::
string>(
"digiCollection")),
61 digiProducer_(iConfig.getParameter<
std::
string>(
"digiProducer")),
62 eventHeaderCollection_(iConfig.getParameter<
std::
string>(
"eventHeaderCollection")),
63 eventHeaderProducer_(iConfig.getParameter<
std::
string>(
"eventHeaderProducer")),
88 sampfile +=
"/TmpTreeMatacqAnalyzer.root";
94 tree =
new TTree(
"MatacqTree",
"MatacqTree");
100 tree->Branch(
"matacq", &
matacq,
"matacq[2560]/D");
103 tree->Branch(
"tt", &
tt,
"tt/D");
111 tree->SetBranchAddress(
"tt", &
tt);
116 std::stringstream namefile;
117 namefile <<
resdir_ <<
"/MATACQ.root";
139 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- Matacq Digis Found -- ";
141 edm::LogError(
"EcalMatacqAnalyzzer") <<
"Error! can't get the product EcalMatacqDigi producer:" 151 edm::LogError(
"EcalMatacqAnalyzzer") <<
"Error! can't get the product EcalRawData producer:" 162 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- Before header -- ";
173 int fed = headerItr->fedId();
178 runType = headerItr->getRunType();
179 runNum = headerItr->getRunNumber();
180 event = headerItr->getLV1();
184 <<
"-- debug test -- runtype:" <<
runType <<
" event:" <<
event <<
" runNum:" <<
runNum;
186 dccID = headerItr->getDccInTCCCommand();
187 fedID = headerItr->fedId();
198 <<
"-- debug test -- Inside header before fed cut -- color=" <<
color <<
", dcc=" <<
dccID 208 <<
"-- debug test -- Inside header after fed cut -- color=" <<
color <<
", dcc=" <<
dccID <<
", fed=" <<
fedID 219 if (iter ==
colors.end()) {
246 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- Inside digis -- digi size=" << digis.
size();
249 if (digis.
size() == 0)
259 for (
int i = 0;
i < digis.
size(); ++
i) {
268 <<
"-- debug test -- Inside digis -- nsamples=" <<
nsamples <<
", max=" <<
max;
284 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
286 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
292 std::stringstream del2;
294 system(del2.str().c_str());
300 unsigned int nCol =
colors.size();
302 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
303 for (
unsigned int iSide = 0; iSide <
nSide; iSide++) {
311 TProfile* shapeMatTmp =
new TProfile(
314 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
315 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+ Analyzing MATACQ data +=+";
321 mtqShape =
new TTree(
"MatacqShape",
"MatacqShape");
358 unsigned int endsample;
359 unsigned int presample;
362 TChain* fChain = (TChain*)
tree;
363 Long64_t nentries = fChain->GetEntriesFast();
364 Long64_t nbytes = 0, nb = 0;
366 for (Long64_t jentry = 0; jentry < nentries; jentry++) {
368 Long64_t ientry = fChain->LoadTree(jentry);
371 nb = fChain->GetEntry(jentry);
390 <<
"-- debug test -- inside loop 1 -- jentry:" << jentry <<
" over nentries=" << nentries;
409 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 2 -- ";
418 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 3 -- ped:" <<
ped;
425 if (mtq->
doFit() == 0) {
452 <<
"-- debug test -- inside loop 7 -- firstS:" << firstS <<
", nsamples:" <<
nsamples;
454 if (firstS >= 0 && lastS <=
nsamples) {
455 for (
int i = firstS;
i < lastS;
i++) {
456 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
468 for (
int i = firstS;
i < 0;
i++) {
469 shapeMatTmp->Fill(
double(
i) - firstS, thisped);
479 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
488 shapeMatTmp->Fill(
double(
i) - firstS, matacqval);
493 for (
int i = firstSBis;
i < lastS;
i++) {
494 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
500 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 8";
505 for (
unsigned int i = 0;
i < nCol;
i++) {
513 <<
"-- debug test -- inside loop 8bis color:" <<
color <<
" iCol:" << iCol <<
" nCol:" << nCol;
518 MTQ[iCol][
lightside]->addEntry(
peak,
sigma,
fit,
ampl,
trise,
fwhm,
fw20,
fw80,
ped,
pedsig,
sliding);
523 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 9";
534 double Peak[6], Sigma[6],
Fit[6], Ampl[6], Trise[6], Fwhm[6], Fw20[6], Fw80[6], Ped[6], Pedsig[6], Sliding[6];
537 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
538 std::stringstream nametree;
539 nametree <<
"MatacqCol" <<
colors[iColor];
540 meanTree[iColor] =
new TTree(nametree.str().c_str(), nametree.str().c_str());
542 meanTree[iColor]->Branch(
"peak", &Peak,
"Peak[6]/D");
543 meanTree[iColor]->Branch(
"sigma", &Sigma,
"Sigma[6]/D");
545 meanTree[iColor]->Branch(
"ampl", &Ampl,
"Ampl[6]/D");
546 meanTree[iColor]->Branch(
"trise", &Trise,
"Trise[6]/D");
547 meanTree[iColor]->Branch(
"fwhm", &Fwhm,
"Fwhm[6]/D");
548 meanTree[iColor]->Branch(
"fw20", &Fw20,
"Fw20[6]/D");
549 meanTree[iColor]->Branch(
"fw80", &Fw80,
"Fw80[6]/D");
550 meanTree[iColor]->Branch(
"ped", &Ped,
"Ped[6]/D");
551 meanTree[iColor]->Branch(
"pedsig", &Pedsig,
"Pedsig[6]/D");
552 meanTree[iColor]->Branch(
"sliding", &Sliding,
"Sliding[6]/D");
555 meanTree[iColor]->SetBranchAddress(
"peak", Peak);
556 meanTree[iColor]->SetBranchAddress(
"sigma", Sigma);
558 meanTree[iColor]->SetBranchAddress(
"ampl", Ampl);
559 meanTree[iColor]->SetBranchAddress(
"fwhm", Fwhm);
560 meanTree[iColor]->SetBranchAddress(
"fw20", Fw20);
561 meanTree[iColor]->SetBranchAddress(
"fw80", Fw80);
562 meanTree[iColor]->SetBranchAddress(
"trise", Trise);
563 meanTree[iColor]->SetBranchAddress(
"ped", Ped);
564 meanTree[iColor]->SetBranchAddress(
"pedsig", Pedsig);
565 meanTree[iColor]->SetBranchAddress(
"sliding", Sliding);
568 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
569 for (
unsigned int iSide = 0; iSide <
nSides; iSide++) {
576 for (
unsigned int i = 0;
i <
val[iVar].size();
i++) {
579 Peak[
i] =
val[iVar].at(
i);
582 Sigma[
i] =
val[iVar].at(
i);
588 Ampl[
i] =
val[iVar].at(
i);
591 Fwhm[
i] =
val[iVar].at(
i);
594 Fw20[
i] =
val[iVar].at(
i);
597 Fw80[
i] =
val[iVar].at(
i);
600 Trise[
i] =
val[iVar].at(
i);
603 Ped[
i] =
val[iVar].at(
i);
606 Pedsig[
i] =
val[iVar].at(
i);
609 Sliding[
i] =
val[iVar].at(
i);
616 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside final loop ";
622 int im = shapeMatTmp->GetMaximumBin();
623 double q1 = shapeMatTmp->GetBinContent(im - 1);
624 double q2 = shapeMatTmp->GetBinContent(im);
625 double q3 = shapeMatTmp->GetBinContent(im + 1);
627 double a2 = (q3 + q1) / 2.0 - q2;
628 double a1 = q2 - q1 +
a2 * (1 - 2 * im);
629 double a0 = q2 - a1 * im -
a2 * im * im;
631 double am =
a0 - a1 * a1 / (4 *
a2);
637 bl += shapeMatTmp->GetBinContent(
i);
644 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- computing shape ";
650 height = shapeMatTmp->GetBinContent(
i) - bl;
660 for (
unsigned int i = firstBin;
i < lastBin;
i++) {
661 shapeMat->Fill(
i - firstBin, shapeMatTmp->GetBinContent(
i) - bl);
665 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
679 std::stringstream del2;
681 system(del2.str().c_str());
684 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+ .................... done +=+";
685 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
Log< level::Info, true > LogVerbatim
const unsigned int _timeaftmax
const unsigned int _thres
EcalMatacqAnalyzer(const edm::ParameterSet &iConfig)
const unsigned int _slide
const unsigned int _lowlev
const std::string digiCollection_
T const * product() const
const unsigned int _presampleshape
std::vector< T >::const_iterator const_iterator
TMTQ * MTQ[nColor][nSide]
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const std::string resdir_
float adcCount(const int &i) const
const std::string eventHeaderCollection_
void analyze(const edm::Event &e, const edm::EventSetup &c) override
const unsigned int _nevlasers
std::vector< double > get(int)
#define DEFINE_FWK_MODULE(type)
const_iterator begin() const
int rawPulseAnalysis(Int_t, Double_t *)
const unsigned int _timebefmax
const_iterator end() const
const std::string eventHeaderProducer_
const unsigned int _parabnbefmax
const edm::EDGetTokenT< EcalMatacqDigiCollection > pmatToken_
static constexpr float a0
const std::string digiProducer_
const unsigned int _nsamplesaftmax
const unsigned int _nsamplesshape
const unsigned int _noiseCut
const edm::EDGetTokenT< EcalRawDataCollection > dccToken_
const unsigned int _highlev
const unsigned int _parabnaftmax