46 _presample(iConfig.getUntrackedParameter<double>(
"nPresamples", 6.7)),
47 _nsamplesaftmax(iConfig.getUntrackedParameter<unsigned int>(
"nSamplesAftMax", 80)),
48 _noiseCut(iConfig.getUntrackedParameter<unsigned int>(
"noiseCut", 7)),
49 _parabnbefmax(iConfig.getUntrackedParameter<unsigned int>(
"paraBeforeMax", 8)),
50 _parabnaftmax(iConfig.getUntrackedParameter<unsigned int>(
"paraAfterMax", 7)),
51 _thres(iConfig.getUntrackedParameter<unsigned int>(
"threshold", 10)),
52 _lowlev(iConfig.getUntrackedParameter<unsigned int>(
"lowLevel", 20)),
53 _highlev(iConfig.getUntrackedParameter<unsigned int>(
"highLevel", 80)),
54 _nevlasers(iConfig.getUntrackedParameter<unsigned int>(
"nEventLaser", 600)),
55 _timebefmax(iConfig.getUntrackedParameter<unsigned int>(
"timeBefMax", 100)),
56 _timeaftmax(iConfig.getUntrackedParameter<unsigned int>(
"timeAftMax", 250)),
57 _cutwindow(iConfig.getUntrackedParameter<double>(
"cutWindow", 0.1)),
58 _nsamplesshape(iConfig.getUntrackedParameter<unsigned int>(
"nSamplesShape", 250)),
59 _presampleshape(iConfig.getUntrackedParameter<unsigned int>(
"nPresamplesShape", 50)),
60 _slide(iConfig.getUntrackedParameter<unsigned int>(
"nSlide", 100)),
61 _fedid(iConfig.getUntrackedParameter<int>(
"fedID", -999)),
62 _debug(iConfig.getUntrackedParameter<int>(
"debug", 0)),
101 sampfile +=
"/TmpTreeMatacqAnalyzer.root";
107 tree =
new TTree(
"MatacqTree",
"MatacqTree");
111 tree->Branch(
"event", &
event,
"event/I");
112 tree->Branch(
"color", &
color,
"color/I");
113 tree->Branch(
"matacq", &
matacq,
"matacq[2560]/D");
114 tree->Branch(
"nsamples", &
nsamples,
"nsamples/I");
115 tree->Branch(
"maxsamp", &
maxsamp,
"maxsamp/I");
116 tree->Branch(
"tt", &
tt,
"tt/D");
117 tree->Branch(
"lightside", &
lightside,
"lightside/I");
119 tree->SetBranchAddress(
"event", &
event);
120 tree->SetBranchAddress(
"color", &
color);
121 tree->SetBranchAddress(
"matacq",
matacq);
122 tree->SetBranchAddress(
"nsamples", &
nsamples);
123 tree->SetBranchAddress(
"maxsamp", &
maxsamp);
124 tree->SetBranchAddress(
"tt", &
tt);
125 tree->SetBranchAddress(
"lightside", &
lightside);
129 std::stringstream namefile;
130 namefile <<
resdir_ <<
"/MATACQ.root";
145 std::cout <<
"-- debug test -- Entering Analyze -- event= " <<
iEvent << std::endl;
152 matacqDigi = pmatacqDigi.
product();
154 std::cout <<
"-- debug test -- Matacq Digis Found -- " << std::endl;
160 std::cout <<
"-- debug test -- No Matacq Digis Found -- " << std::endl;
170 DCCHeader = pDCCHeader.
product();
182 std::cout <<
"-- debug test -- Before header -- " << std::endl;
193 int fed = headerItr->fedId();
198 runType = headerItr->getRunType();
199 runNum = headerItr->getRunNumber();
200 event = headerItr->getLV1();
203 std::cout <<
"-- debug test -- runtype:" <<
runType <<
" event:" <<
event <<
" runNum:" <<
runNum << std::endl;
205 dccID = headerItr->getDccInTCCCommand();
206 fedID = headerItr->fedId();
216 std::cout <<
"-- debug test -- Inside header before fed cut -- color=" <<
color <<
", dcc=" <<
dccID
225 std::cout <<
"-- debug test -- Inside header after fed cut -- color=" <<
color <<
", dcc=" <<
dccID
236 if (iter ==
colors.end()) {
243 std::cout <<
"-- debug test -- Before digis -- Event:" <<
iEvent << std::endl;
263 std::cout <<
"-- debug test -- Inside digis -- digi size=" << digis.
size() << std::endl;
266 if (digis.
size() == 0)
276 for (
int i = 0;
i < digis.
size(); ++
i) {
284 std::cout <<
"-- debug test -- Inside digis -- nsamples=" <<
nsamples <<
", max=" << max << std::endl;
291 std::cout <<
"-- debug test -- After digis -- Event: " <<
iEvent << std::endl;
300 std::cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
301 std::cout <<
"\t+=+ WARNING! NO MATACQ +=+" << std::endl;
302 std::cout <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
306 test = fopen(
sampfile.c_str(),
"r");
308 std::stringstream del2;
310 system(del2.str().c_str());
316 unsigned int nCol =
colors.size();
318 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
319 for (
unsigned int iSide = 0; iSide <
nSide; iSide++) {
327 TProfile* shapeMatTmp =
new TProfile(
330 std::cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
331 std::cout <<
"\t+=+ Analyzing MATACQ data +=+" << std::endl;
337 mtqShape =
new TTree(
"MatacqShape",
"MatacqShape");
374 unsigned int endsample;
375 unsigned int presample;
378 TChain* fChain = (TChain*)
tree;
379 Long64_t nentries = fChain->GetEntriesFast();
380 Long64_t nbytes = 0, nb = 0;
382 for (Long64_t jentry = 0; jentry < nentries; jentry++) {
384 Long64_t ientry = fChain->LoadTree(jentry);
387 nb = fChain->GetEntry(jentry);
405 std::cout <<
"-- debug test -- inside loop 1 -- jentry:" << jentry <<
" over nentries=" << nentries << std::endl;
424 std::cout <<
"-- debug test -- inside loop 2 -- " << std::endl;
433 std::cout <<
"-- debug test -- inside loop 3 -- ped:" <<
ped << std::endl;
439 std::cout <<
"-- debug test -- inside loop 4 -- peak:" <<
peak << std::endl;
440 if (mtq->
doFit() == 0) {
449 std::cout <<
"-- debug test -- inside loop 4 -- ampl:" <<
ampl << std::endl;
454 std::cout <<
"-- debug test -- inside loop 5 -- trise:" <<
trise << std::endl;
458 std::cout <<
"-- debug test -- inside loop 6 -- status:" <<
status << std::endl;
466 std::cout <<
"-- debug test -- inside loop 7 -- firstS:" << firstS <<
", nsamples:" <<
nsamples << std::endl;
468 if (firstS >= 0 && lastS <=
nsamples) {
469 for (
int i = firstS;
i < lastS;
i++) {
470 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
482 for (
int i = firstS;
i < 0;
i++) {
483 shapeMatTmp->Fill(
double(
i) - firstS, thisped);
493 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
502 shapeMatTmp->Fill(
double(
i) - firstS, matacqval);
507 for (
int i = firstSBis;
i < lastS;
i++) {
508 shapeMatTmp->Fill(
double(
i) - firstS,
matacq[
i]);
514 std::cout <<
"-- debug test -- inside loop 8" << std::endl;
519 for (
unsigned int i = 0;
i < nCol;
i++) {
526 std::cout <<
"-- debug test -- inside loop 8bis color:" <<
color <<
" iCol:" << iCol <<
" nCol:" << nCol
532 MTQ[iCol][
lightside]->addEntry(
peak,
sigma,
fit,
ampl,
trise,
fwhm,
fw20,
fw80,
ped,
pedsig,
sliding);
537 std::cout <<
"-- debug test -- inside loop 9" << std::endl;
545 std::cout <<
"-- debug test -- after loop " << std::endl;
548 double Peak[6], Sigma[6],
Fit[6], Ampl[6], Trise[6], Fwhm[6], Fw20[6], Fw80[6], Ped[6], Pedsig[6], Sliding[6];
551 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
552 std::stringstream nametree;
553 nametree <<
"MatacqCol" <<
colors[iColor];
554 meanTree[iColor] =
new TTree(nametree.str().c_str(), nametree.str().c_str());
555 meanTree[iColor]->Branch(
"side", &Side,
"Side/I");
556 meanTree[iColor]->Branch(
"peak", &Peak,
"Peak[6]/D");
557 meanTree[iColor]->Branch(
"sigma", &Sigma,
"Sigma[6]/D");
558 meanTree[iColor]->Branch(
"fit", &Fit,
"Fit[6]/D");
559 meanTree[iColor]->Branch(
"ampl", &Ampl,
"Ampl[6]/D");
560 meanTree[iColor]->Branch(
"trise", &Trise,
"Trise[6]/D");
561 meanTree[iColor]->Branch(
"fwhm", &Fwhm,
"Fwhm[6]/D");
562 meanTree[iColor]->Branch(
"fw20", &Fw20,
"Fw20[6]/D");
563 meanTree[iColor]->Branch(
"fw80", &Fw80,
"Fw80[6]/D");
564 meanTree[iColor]->Branch(
"ped", &Ped,
"Ped[6]/D");
565 meanTree[iColor]->Branch(
"pedsig", &Pedsig,
"Pedsig[6]/D");
566 meanTree[iColor]->Branch(
"sliding", &Sliding,
"Sliding[6]/D");
568 meanTree[iColor]->SetBranchAddress(
"side", &Side);
569 meanTree[iColor]->SetBranchAddress(
"peak", Peak);
570 meanTree[iColor]->SetBranchAddress(
"sigma", Sigma);
571 meanTree[iColor]->SetBranchAddress(
"fit", Fit);
572 meanTree[iColor]->SetBranchAddress(
"ampl", Ampl);
573 meanTree[iColor]->SetBranchAddress(
"fwhm", Fwhm);
574 meanTree[iColor]->SetBranchAddress(
"fw20", Fw20);
575 meanTree[iColor]->SetBranchAddress(
"fw80", Fw80);
576 meanTree[iColor]->SetBranchAddress(
"trise", Trise);
577 meanTree[iColor]->SetBranchAddress(
"ped", Ped);
578 meanTree[iColor]->SetBranchAddress(
"pedsig", Pedsig);
579 meanTree[iColor]->SetBranchAddress(
"sliding", Sliding);
582 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
583 for (
unsigned int iSide = 0; iSide <
nSides; iSide++) {
588 val[iVar] =
MTQ[iCol][iSide]->
get(iVar);
590 for (
unsigned int i = 0;
i < val[iVar].size();
i++) {
593 Peak[
i] = val[iVar].at(
i);
596 Sigma[
i] = val[iVar].at(
i);
599 Fit[
i] = val[iVar].at(
i);
602 Ampl[
i] = val[iVar].at(
i);
605 Fwhm[
i] = val[iVar].at(
i);
608 Fw20[
i] = val[iVar].at(
i);
611 Fw80[
i] = val[iVar].at(
i);
614 Trise[
i] = val[iVar].at(
i);
617 Ped[
i] = val[iVar].at(
i);
620 Pedsig[
i] = val[iVar].at(
i);
623 Sliding[
i] = val[iVar].at(
i);
630 std::cout <<
"-- debug test -- inside final loop " << std::endl;
636 int im = shapeMatTmp->GetMaximumBin();
637 double q1 = shapeMatTmp->GetBinContent(im - 1);
638 double q2 = shapeMatTmp->GetBinContent(im);
639 double q3 = shapeMatTmp->GetBinContent(im + 1);
641 double a2 = (q3 + q1) / 2.0 - q2;
642 double a1 = q2 - q1 + a2 * (1 - 2 * im);
643 double a0 = q2 - a1 * im - a2 * im * im;
645 double am = a0 - a1 * a1 / (4 *
a2);
651 bl += shapeMatTmp->GetBinContent(
i);
658 std::cout <<
"-- debug test -- computing shape " << std::endl;
664 height = shapeMatTmp->GetBinContent(
i) - bl;
674 for (
unsigned int i = firstBin;
i < lastBin;
i++) {
675 shapeMat->Fill(
i - firstBin, shapeMatTmp->GetBinContent(
i) - bl);
679 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
683 std::cout <<
"-- debug test -- writing " << std::endl;
691 test = fopen(
sampfile.c_str(),
"r");
693 std::stringstream del2;
695 system(del2.str().c_str());
698 std::cout <<
"\t+=+ .................... done +=+" << std::endl;
699 std::cout <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
unsigned int _presampleshape
EcalMatacqAnalyzer(const edm::ParameterSet &iConfig)
std::vector< int > colors
#define DEFINE_FWK_MODULE(type)
unsigned int _nsamplesshape
std::vector< T >::const_iterator const_iterator
float adcCount(const int &i) const
std::string eventHeaderProducer_
TMTQ * MTQ[nColor][nSide]
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
std::string eventHeaderCollection_
std::string digiProducer_
std::vector< double > get(int)
if(conf_.getParameter< bool >("UseStripCablingDB"))
int rawPulseAnalysis(Int_t, Double_t *)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
~EcalMatacqAnalyzer() override
const_iterator end() const
unsigned int _parabnaftmax
T const * product() const
static constexpr float a0
T getParameter(std::string const &) const
std::string digiCollection_
unsigned int _nsamplesaftmax
const_iterator begin() const
unsigned int _parabnbefmax