47 _presample( iConfig.getUntrackedParameter< double >(
"nPresamples", 6.7 ) ),
48 _nsamplesaftmax(iConfig.getUntrackedParameter< unsigned
int >(
"nSamplesAftMax", 80 ) ),
49 _noiseCut( iConfig.getUntrackedParameter< unsigned
int >(
"noiseCut", 7 ) ),
50 _parabnbefmax( iConfig.getUntrackedParameter< unsigned
int >(
"paraBeforeMax", 8 ) ),
51 _parabnaftmax( iConfig.getUntrackedParameter< unsigned
int >(
"paraAfterMax", 7 ) ),
52 _thres( iConfig.getUntrackedParameter< unsigned
int >(
"threshold", 10 ) ),
53 _lowlev( iConfig.getUntrackedParameter< unsigned
int >(
"lowLevel", 20 ) ),
54 _highlev( iConfig.getUntrackedParameter< unsigned
int >(
"highLevel", 80 ) ),
55 _nevlasers( iConfig.getUntrackedParameter< unsigned
int >(
"nEventLaser", 600 ) ),
56 _timebefmax( iConfig.getUntrackedParameter< unsigned
int >(
"timeBefMax", 100 ) ),
57 _timeaftmax( iConfig.getUntrackedParameter< unsigned
int >(
"timeAftMax", 250 ) ),
58 _cutwindow( iConfig.getUntrackedParameter< double >(
"cutWindow", 0.1 ) ),
59 _nsamplesshape( iConfig.getUntrackedParameter< unsigned
int >(
"nSamplesShape", 250 ) ),
60 _presampleshape(iConfig.getUntrackedParameter< unsigned
int >(
"nPresamplesShape",50 ) ),
61 _slide( iConfig.getUntrackedParameter< unsigned
int >(
"nSlide", 100 ) ),
62 _fedid( iConfig.getUntrackedParameter<
int >(
"fedID", -999 ) ),
63 _debug( iConfig.getUntrackedParameter<
int >(
"debug", 0 ) ),
64 nSides(
NSIDES), lightside(0), runType(-1), runNum(0),
101 sampfile+=
"/TmpTreeMatacqAnalyzer.root";
108 tree =
new TTree(
"MatacqTree",
"MatacqTree");
113 tree->Branch(
"event", &
event,
"event/I" );
114 tree->Branch(
"color", &
color ,
"color/I" );
115 tree->Branch(
"matacq", &
matacq ,
"matacq[2560]/D" );
116 tree->Branch(
"nsamples", &
nsamples ,
"nsamples/I" );
117 tree->Branch(
"maxsamp", &
maxsamp ,
"maxsamp/I" );
118 tree->Branch(
"tt", &
tt ,
"tt/D" );
119 tree->Branch(
"lightside", &
lightside ,
"lightside/I" );
121 tree->SetBranchAddress(
"event", &
event );
122 tree->SetBranchAddress(
"color", &
color );
123 tree->SetBranchAddress(
"matacq",
matacq );
124 tree->SetBranchAddress(
"nsamples", &
nsamples );
125 tree->SetBranchAddress(
"maxsamp", &
maxsamp );
126 tree->SetBranchAddress(
"tt", &
tt );
127 tree->SetBranchAddress(
"lightside", &
lightside );
133 std::stringstream namefile;
134 namefile <<
resdir_ <<
"/MATACQ.root";
158 matacqDigi=pmatacqDigi.
product();
159 if (
_debug==1 )
std::cout <<
"-- debug test -- Matacq Digis Found -- "<< std::endl;
163 if (
_debug==1 )
std::cout <<
"-- debug test -- No Matacq Digis Found -- "<< std::endl;
173 DCCHeader=pDCCHeader.
product();
183 if (
_debug==1)
std::cout <<
"-- debug test -- Before header -- "<< std::endl;
190 if(
color<0 )
return;
194 int fed = headerItr->fedId();
198 runType=headerItr->getRunType();
199 runNum=headerItr->getRunNumber();
200 event=headerItr->getLV1();
204 dccID=headerItr->getDccInTCCCommand();
205 fedID=headerItr->fedId();
259 std::cout <<
"-- debug test -- Inside digis -- digi size="<<digis.
size()<< std::endl;
262 if(digis.
size()== 0 )
continue;
270 for(
int i=0;
i<digis.
size(); ++
i){
278 std::cout <<
"-- debug test -- Inside digis -- nsamples="<<
nsamples<<
", max="<<max<< std::endl;
297 std::cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
298 std::cout <<
"\t+=+ WARNING! NO MATACQ +=+" << std::endl;
299 std::cout <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
306 std::stringstream del2;
308 system(del2.str().c_str());
314 unsigned int nCol=
colors.size();
316 for(
unsigned int iCol=0;iCol<nCol;iCol++){
317 for(
unsigned int iSide=0;iSide<
nSide;iSide++){
327 std::cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
328 std::cout <<
"\t+=+ Analyzing MATACQ data +=+" << std::endl;
335 mtqShape =
new TTree(
"MatacqShape",
"MatacqShape");
373 unsigned int endsample;
374 unsigned int presample;
379 TChain* fChain = (TChain*)
tree;
380 Long64_t nentries = fChain->GetEntriesFast();
381 Long64_t nbytes = 0, nb = 0;
383 for( Long64_t jentry=0; jentry<nentries; jentry++ )
386 Long64_t ientry = fChain->LoadTree(jentry);
387 if (ientry < 0)
break;
388 nb = fChain->GetEntry( jentry ); nbytes += nb;
405 if (
_debug==1)
std::cout <<
"-- debug test -- inside loop 1 -- jentry:"<<jentry<<
" over nentries="<<nentries<< std::endl;
416 if (
_debug==1)
std::cout <<
"-- debug test -- inside loop 2 -- "<< std::endl;
432 if( mtq->
doFit()==0 )
458 if (
_debug==1)
std::cout <<
"-- debug test -- inside loop 7 -- firstS:"<<firstS<<
", nsamples:"<<
nsamples<< std::endl;
462 for (
int i=firstS;
i<lastS;
i++){
463 shapeMatTmp->Fill(
double(
i)-firstS,
matacq[
i]);
477 for(
int i=firstS;
i<0;
i++){
478 shapeMatTmp->Fill(
double(
i)-firstS,thisped);
490 shapeMatTmp->Fill(
double(
i)-firstS,
matacq[
i]);
499 shapeMatTmp->Fill(
double(
i)-firstS,matacqval);
504 for (
int i=firstSBis;
i<lastS;
i++){
505 shapeMatTmp->Fill(
double(
i)-firstS,
matacq[
i]);
511 if (
_debug==1)
std::cout <<
"-- debug test -- inside loop 8"<< std::endl;
516 for(
unsigned int i=0;
i<nCol;
i++){
522 if (
_debug==1)
std::cout <<
"-- debug test -- inside loop 8bis color:"<<
color<<
" iCol:"<<iCol<<
" nCol:"<< nCol<< std::endl;
526 if(
status == 1 && mtq->
findPeak()==0 && mtq->
doFit()==0 && mtq->
compute_trise()==0 )
MTQ[iCol][
lightside]->
addEntry(
peak,
sigma,
fit,
ampl,
trise,
fwhm,
fw20,
fw80,
ped,
pedsig,
sliding);
530 if (
_debug==1)
std::cout <<
"-- debug test -- inside loop 9"<< std::endl;
540 double Peak[6], Sigma[6],
Fit[6], Ampl[6], Trise[6], Fwhm[6], Fw20[6], Fw80[6], Ped[6], Pedsig[6], Sliding[6];
543 for (
unsigned int iColor=0;iColor<nCol;iColor++){
545 std::stringstream nametree;
546 nametree <<
"MatacqCol"<<
colors[iColor];
547 meanTree[iColor]=
new TTree(nametree.str().c_str(),nametree.str().c_str());
548 meanTree[iColor]->Branch(
"side", &Side ,
"Side/I" );
549 meanTree[iColor]->Branch(
"peak", &Peak ,
"Peak[6]/D" );
550 meanTree[iColor]->Branch(
"sigma", &Sigma ,
"Sigma[6]/D" );
551 meanTree[iColor]->Branch(
"fit", &Fit ,
"Fit[6]/D" );
552 meanTree[iColor]->Branch(
"ampl", &Ampl ,
"Ampl[6]/D" );
553 meanTree[iColor]->Branch(
"trise", &Trise ,
"Trise[6]/D" );
554 meanTree[iColor]->Branch(
"fwhm", &Fwhm ,
"Fwhm[6]/D" );
555 meanTree[iColor]->Branch(
"fw20", &Fw20 ,
"Fw20[6]/D" );
556 meanTree[iColor]->Branch(
"fw80", &Fw80 ,
"Fw80[6]/D" );
557 meanTree[iColor]->Branch(
"ped", &Ped ,
"Ped[6]/D" );
558 meanTree[iColor]->Branch(
"pedsig", &Pedsig ,
"Pedsig[6]/D" );
559 meanTree[iColor]->Branch(
"sliding", &Sliding ,
"Sliding[6]/D" );
561 meanTree[iColor]->SetBranchAddress(
"side", &Side );
562 meanTree[iColor]->SetBranchAddress(
"peak", Peak );
563 meanTree[iColor]->SetBranchAddress(
"sigma", Sigma );
564 meanTree[iColor]->SetBranchAddress(
"fit", Fit );
565 meanTree[iColor]->SetBranchAddress(
"ampl", Ampl );
566 meanTree[iColor]->SetBranchAddress(
"fwhm", Fwhm );
567 meanTree[iColor]->SetBranchAddress(
"fw20", Fw20 );
568 meanTree[iColor]->SetBranchAddress(
"fw80", Fw80 );
569 meanTree[iColor]->SetBranchAddress(
"trise", Trise );
570 meanTree[iColor]->SetBranchAddress(
"ped", Ped );
571 meanTree[iColor]->SetBranchAddress(
"pedsig", Pedsig );
572 meanTree[iColor]->SetBranchAddress(
"sliding", Sliding );
576 for(
unsigned int iCol=0;iCol<nCol;iCol++){
577 for(
unsigned int iSide=0;iSide<
nSides;iSide++){
583 val[iVar] =
MTQ[iCol][iSide]->
get(iVar);
585 for(
unsigned int i=0;
i<val[iVar].size();
i++){
604 if (
_debug==1)
std::cout <<
"-- debug test -- inside final loop "<< std::endl;
610 int im = shapeMatTmp->GetMaximumBin();
611 double q1=shapeMatTmp->GetBinContent(im-1);
612 double q2=shapeMatTmp->GetBinContent(im);
613 double q3=shapeMatTmp->GetBinContent(im+1);
615 double a2=(q3+
q1)/2.0-q2;
616 double a1=q2-q1+a2*(1-2*im);
617 double a0=q2-a1*im-a2*im*im;
619 double am=a0-a1*a1/(4*a2);
626 bl+=shapeMatTmp->GetBinContent(
i);
632 if (
_debug==1)
std::cout <<
"-- debug test -- computing shape "<< std::endl;
638 height=shapeMatTmp->GetBinContent(
i)-bl;
648 for(
unsigned int i=firstBin;
i<lastBin;
i++){
649 shapeMat->Fill(
i-firstBin,shapeMatTmp->GetBinContent(
i)-bl);
653 for (
unsigned int iColor=0;iColor<nCol;iColor++){
666 std::stringstream del2;
668 system(del2.str().c_str());
671 std::cout <<
"\t+=+ .................... done +=+" << std::endl;
672 std::cout <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int _presampleshape
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
EcalMatacqAnalyzer(const edm::ParameterSet &iConfig)
#define DEFINE_FWK_MODULE(type)
unsigned int _nsamplesshape
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
std::string eventHeaderProducer_
TMTQ * MTQ[nColor][nSide]
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const float adcCount(const int &i) const
def addEntry(schema, datatableName, entryinfo, branchinfo)
std::string eventHeaderCollection_
std::string digiProducer_
std::vector< double > get(int)
int rawPulseAnalysis(Int_t, Double_t *)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const_iterator end() const
unsigned int _parabnaftmax
T const * product() const
std::string digiCollection_
unsigned int _nsamplesaftmax
const_iterator begin() const
unsigned int _parabnbefmax