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();
365 for (Long64_t jentry = 0; jentry < nentries; jentry++) {
367 Long64_t ientry = fChain->LoadTree(jentry);
370 fChain->GetEntry(jentry);
388 <<
"-- debug test -- inside loop 1 -- jentry:" << jentry <<
" over nentries=" << nentries;
407 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 2 -- ";
416 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 3 -- ped:" <<
ped;
423 if (mtq->
doFit() == 0) {
450 <<
"-- debug test -- inside loop 7 -- firstS:" << firstS <<
", nsamples:" <<
nsamples;
452 if (firstS >= 0 && lastS <=
nsamples) {
453 for (
int i = firstS;
i < lastS;
i++) {
454 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
466 for (
int i = firstS;
i < 0;
i++) {
467 shapeMatTmp->Fill(
double(
i) - firstS, thisped);
477 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
486 shapeMatTmp->Fill(
double(
i) - firstS, matacqval);
491 for (
int i = firstSBis;
i < lastS;
i++) {
492 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
498 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 8";
503 for (
unsigned int i = 0;
i < nCol;
i++) {
511 <<
"-- debug test -- inside loop 8bis color:" <<
color <<
" iCol:" << iCol <<
" nCol:" << nCol;
516 MTQ[iCol][
lightside]->addEntry(
peak,
sigma,
fit,
ampl,
trise,
fwhm,
fw20,
fw80,
ped,
pedsig,
sliding);
521 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 9";
532 double Peak[6], Sigma[6],
Fit[6], Ampl[6], Trise[6], Fwhm[6], Fw20[6], Fw80[6], Ped[6], Pedsig[6], Sliding[6];
535 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
536 std::stringstream nametree;
537 nametree <<
"MatacqCol" <<
colors[iColor];
538 meanTree[iColor] =
new TTree(nametree.str().c_str(), nametree.str().c_str());
540 meanTree[iColor]->Branch(
"peak", &Peak,
"Peak[6]/D");
541 meanTree[iColor]->Branch(
"sigma", &Sigma,
"Sigma[6]/D");
543 meanTree[iColor]->Branch(
"ampl", &Ampl,
"Ampl[6]/D");
544 meanTree[iColor]->Branch(
"trise", &Trise,
"Trise[6]/D");
545 meanTree[iColor]->Branch(
"fwhm", &Fwhm,
"Fwhm[6]/D");
546 meanTree[iColor]->Branch(
"fw20", &Fw20,
"Fw20[6]/D");
547 meanTree[iColor]->Branch(
"fw80", &Fw80,
"Fw80[6]/D");
548 meanTree[iColor]->Branch(
"ped", &Ped,
"Ped[6]/D");
549 meanTree[iColor]->Branch(
"pedsig", &Pedsig,
"Pedsig[6]/D");
550 meanTree[iColor]->Branch(
"sliding", &Sliding,
"Sliding[6]/D");
553 meanTree[iColor]->SetBranchAddress(
"peak", Peak);
554 meanTree[iColor]->SetBranchAddress(
"sigma", Sigma);
556 meanTree[iColor]->SetBranchAddress(
"ampl", Ampl);
557 meanTree[iColor]->SetBranchAddress(
"fwhm", Fwhm);
558 meanTree[iColor]->SetBranchAddress(
"fw20", Fw20);
559 meanTree[iColor]->SetBranchAddress(
"fw80", Fw80);
560 meanTree[iColor]->SetBranchAddress(
"trise", Trise);
561 meanTree[iColor]->SetBranchAddress(
"ped", Ped);
562 meanTree[iColor]->SetBranchAddress(
"pedsig", Pedsig);
563 meanTree[iColor]->SetBranchAddress(
"sliding", Sliding);
566 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
567 for (
unsigned int iSide = 0; iSide <
nSides; iSide++) {
574 for (
unsigned int i = 0;
i <
val[iVar].size();
i++) {
577 Peak[
i] =
val[iVar].at(
i);
580 Sigma[
i] =
val[iVar].at(
i);
586 Ampl[
i] =
val[iVar].at(
i);
589 Fwhm[
i] =
val[iVar].at(
i);
592 Fw20[
i] =
val[iVar].at(
i);
595 Fw80[
i] =
val[iVar].at(
i);
598 Trise[
i] =
val[iVar].at(
i);
601 Ped[
i] =
val[iVar].at(
i);
604 Pedsig[
i] =
val[iVar].at(
i);
607 Sliding[
i] =
val[iVar].at(
i);
614 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside final loop ";
620 int im = shapeMatTmp->GetMaximumBin();
621 double q1 = shapeMatTmp->GetBinContent(im - 1);
622 double q2 = shapeMatTmp->GetBinContent(im);
623 double q3 = shapeMatTmp->GetBinContent(im + 1);
625 double a2 = (q3 + q1) / 2.0 - q2;
626 double a1 = q2 - q1 +
a2 * (1 - 2 * im);
627 double a0 = q2 - a1 * im -
a2 * im * im;
629 double am =
a0 - a1 * a1 / (4 *
a2);
635 bl += shapeMatTmp->GetBinContent(
i);
642 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- computing shape ";
648 height = shapeMatTmp->GetBinContent(
i) - bl;
658 for (
unsigned int i = firstBin;
i < lastBin;
i++) {
659 shapeMat->Fill(
i - firstBin, shapeMatTmp->GetBinContent(
i) - bl);
663 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
677 std::stringstream del2;
679 system(del2.str().c_str());
682 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+ .................... done +=+";
683 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