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()) {
244 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- Inside digis -- digi size=" << digis.
size();
247 if (digis.
size() == 0)
257 for (
int i = 0;
i < digis.
size(); ++
i) {
266 <<
"-- debug test -- Inside digis -- nsamples=" <<
nsamples <<
", max=" <<
max;
280 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
282 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
288 std::stringstream del2;
290 system(del2.str().c_str());
296 unsigned int nCol =
colors.size();
298 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
299 for (
unsigned int iSide = 0; iSide <
nSide; iSide++) {
307 TProfile* shapeMatTmp =
new TProfile(
310 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
311 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+ Analyzing MATACQ data +=+";
317 mtqShape =
new TTree(
"MatacqShape",
"MatacqShape");
354 unsigned int endsample;
355 unsigned int presample;
358 TChain* fChain = (TChain*)
tree;
359 Long64_t nentries = fChain->GetEntriesFast();
361 for (Long64_t jentry = 0; jentry < nentries; jentry++) {
363 Long64_t ientry = fChain->LoadTree(jentry);
366 fChain->GetEntry(jentry);
384 <<
"-- debug test -- inside loop 1 -- jentry:" << jentry <<
" over nentries=" << nentries;
403 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 2 -- ";
412 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 3 -- ped:" <<
ped;
419 if (mtq->
doFit() == 0) {
446 <<
"-- debug test -- inside loop 7 -- firstS:" << firstS <<
", nsamples:" <<
nsamples;
448 if (firstS >= 0 && lastS <=
nsamples) {
449 for (
int i = firstS;
i < lastS;
i++) {
450 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
462 for (
int i = firstS;
i < 0;
i++) {
463 shapeMatTmp->Fill(
double(
i) - firstS, thisped);
473 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
482 shapeMatTmp->Fill(
double(
i) - firstS, matacqval);
487 for (
int i = firstSBis;
i < lastS;
i++) {
488 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
494 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 8";
499 for (
unsigned int i = 0;
i < nCol;
i++) {
507 <<
"-- debug test -- inside loop 8bis color:" <<
color <<
" iCol:" << iCol <<
" nCol:" << nCol;
512 MTQ[iCol][
lightside]->addEntry(
peak,
sigma,
fit,
ampl,
trise,
fwhm,
fw20,
fw80,
ped,
pedsig,
sliding);
517 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside loop 9";
528 double Peak[6], Sigma[6],
Fit[6], Ampl[6], Trise[6], Fwhm[6], Fw20[6], Fw80[6], Ped[6], Pedsig[6], Sliding[6];
531 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
532 std::stringstream nametree;
533 nametree <<
"MatacqCol" <<
colors[iColor];
534 meanTree[iColor] =
new TTree(nametree.str().c_str(), nametree.str().c_str());
536 meanTree[iColor]->Branch(
"peak", &Peak,
"Peak[6]/D");
537 meanTree[iColor]->Branch(
"sigma", &Sigma,
"Sigma[6]/D");
539 meanTree[iColor]->Branch(
"ampl", &Ampl,
"Ampl[6]/D");
540 meanTree[iColor]->Branch(
"trise", &Trise,
"Trise[6]/D");
541 meanTree[iColor]->Branch(
"fwhm", &Fwhm,
"Fwhm[6]/D");
542 meanTree[iColor]->Branch(
"fw20", &Fw20,
"Fw20[6]/D");
543 meanTree[iColor]->Branch(
"fw80", &Fw80,
"Fw80[6]/D");
544 meanTree[iColor]->Branch(
"ped", &Ped,
"Ped[6]/D");
545 meanTree[iColor]->Branch(
"pedsig", &Pedsig,
"Pedsig[6]/D");
546 meanTree[iColor]->Branch(
"sliding", &Sliding,
"Sliding[6]/D");
549 meanTree[iColor]->SetBranchAddress(
"peak", Peak);
550 meanTree[iColor]->SetBranchAddress(
"sigma", Sigma);
552 meanTree[iColor]->SetBranchAddress(
"ampl", Ampl);
553 meanTree[iColor]->SetBranchAddress(
"fwhm", Fwhm);
554 meanTree[iColor]->SetBranchAddress(
"fw20", Fw20);
555 meanTree[iColor]->SetBranchAddress(
"fw80", Fw80);
556 meanTree[iColor]->SetBranchAddress(
"trise", Trise);
557 meanTree[iColor]->SetBranchAddress(
"ped", Ped);
558 meanTree[iColor]->SetBranchAddress(
"pedsig", Pedsig);
559 meanTree[iColor]->SetBranchAddress(
"sliding", Sliding);
562 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
563 for (
unsigned int iSide = 0; iSide <
nSides; iSide++) {
570 for (
unsigned int i = 0;
i <
val[iVar].size();
i++) {
573 Peak[
i] =
val[iVar].at(
i);
576 Sigma[
i] =
val[iVar].at(
i);
582 Ampl[
i] =
val[iVar].at(
i);
585 Fwhm[
i] =
val[iVar].at(
i);
588 Fw20[
i] =
val[iVar].at(
i);
591 Fw80[
i] =
val[iVar].at(
i);
594 Trise[
i] =
val[iVar].at(
i);
597 Ped[
i] =
val[iVar].at(
i);
600 Pedsig[
i] =
val[iVar].at(
i);
603 Sliding[
i] =
val[iVar].at(
i);
610 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- inside final loop ";
616 int im = shapeMatTmp->GetMaximumBin();
617 double q1 = shapeMatTmp->GetBinContent(im - 1);
618 double q2 = shapeMatTmp->GetBinContent(im);
619 double q3 = shapeMatTmp->GetBinContent(im + 1);
621 double a2 = (q3 + q1) / 2.0 - q2;
622 double a1 = q2 - q1 +
a2 * (1 - 2 * im);
623 double a0 = q2 - a1 * im -
a2 * im * im;
625 double am =
a0 - a1 * a1 / (4 *
a2);
631 bl += shapeMatTmp->GetBinContent(
i);
638 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"-- debug test -- computing shape ";
644 height = shapeMatTmp->GetBinContent(
i) - bl;
654 for (
unsigned int i = firstBin;
i < lastBin;
i++) {
655 shapeMat->Fill(
i - firstBin, shapeMatTmp->GetBinContent(
i) - bl);
659 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
673 std::stringstream del2;
675 system(del2.str().c_str());
678 edm::LogVerbatim(
"EcalMatacqAnalyzzer") <<
"\t+=+ .................... done +=+";
679 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
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
const unsigned int _parabnaftmax