54 _nsamples( iConfig.getUntrackedParameter< unsigned int >(
"nSamples", 10 ) ),
55 _presample( iConfig.getUntrackedParameter< unsigned int >(
"nPresamples", 3 ) ),
56 _firstsample( iConfig.getUntrackedParameter< unsigned int >(
"firstSample", 1 ) ),
57 _lastsample( iConfig.getUntrackedParameter< unsigned int >(
"lastSample", 2 ) ),
58 _samplemin( iConfig.getUntrackedParameter< unsigned int >(
"sampleMin", 3 ) ),
59 _samplemax( iConfig.getUntrackedParameter< unsigned int >(
"sampleMax", 9 ) ),
60 _nsamplesPN( iConfig.getUntrackedParameter< unsigned int >(
"nSamplesPN", 50 ) ),
61 _presamplePN( iConfig.getUntrackedParameter< unsigned int >(
"nPresamplesPN", 6 ) ),
62 _firstsamplePN( iConfig.getUntrackedParameter< unsigned int >(
"firstSamplePN", 7 ) ),
63 _lastsamplePN( iConfig.getUntrackedParameter< unsigned int >(
"lastSamplePN", 8 ) ),
64 _timingcutlow( iConfig.getUntrackedParameter< unsigned int >(
"timingCutLow", 3 ) ),
65 _timingcuthigh( iConfig.getUntrackedParameter< unsigned int >(
"timingCutHigh", 7 ) ),
66 _niter( iConfig.getUntrackedParameter< unsigned int >(
"nIter", 3 ) ),
67 _fedid( iConfig.getUntrackedParameter< unsigned int >(
"fedID", 0 ) ),
68 _tower( iConfig.getUntrackedParameter< unsigned int >(
"tower", 1 ) ),
69 _channel( iConfig.getUntrackedParameter< unsigned int >(
"channel", 1 ) ),
70 _ecalPart( iConfig.getUntrackedParameter< std::
string >(
"ecalPart",
"EB" ) ),
74 IsFileCreated(0), nCh(0),
75 runType(-1), runNum(0), dccID(-1), lightside(2), doesRefFileExist(0),
76 ttMat(-1), peakMat(-1), peak(-1), evtMat(-1), colMat(-1)
124 stringstream namefile1;
125 namefile1 <<
resdir_<<
"/ADCSamples.root" ;
137 ADCtrees=
new TTree(name.str().c_str(),name.str().c_str());
178 DCCHeader=pDCCHeader.
product();
221 TheMapping = ecalmapping.
product();
223 std::cerr <<
"Error! can't get the product EcalMappingRcd"<< std::endl;
235 int fed = headerItr->fedId();
239 runType=headerItr->getRunType();
240 runNum=headerItr->getRunNumber();
241 event=headerItr->getLV1();
242 dccID=headerItr->getDccInTCCCommand();
243 fedID=headerItr->fedId();
255 stringstream namefile2;
267 test = fopen(namefile.str().c_str(),
"r");
271 matacqFile =
new TFile((namefile.str().c_str()));
291 colors.push_back( color );
292 cout <<
" new color found "<< color<<
" "<<
colors.size()<< endl;
316 unsigned int samplemax=0;
319 std::vector<double> allPNAmpl;
324 for (
int samId=0; samId < (*pnItr).size() ; samId++ ) {
325 pn[samId]=(*pnItr).sample(samId).adc();
332 bl=dsum/((double) _presamplePN);
335 ypnrange[
k]=
pn[
k] - bl;
337 if(ypnrange[k] > val_max) {
338 val_max= ypnrange[
k]; samplemax=
k;
342 chi2pn = pnfit -> doFit(samplemax,&ypnrange[0]);
344 if(chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
pnAmpl=0.;
345 else pnAmpl= pnfit -> getAmpl();
347 allPNAmpl.push_back(
pnAmpl);
380 EBDetId id_crystal(digiItr->id()) ;
383 int etaG = id_crystal.ieta() ;
384 int phiG = id_crystal.iphi() ;
390 etaL=LocalCoord.first ;
391 phiL=LocalCoord.second ;
400 int towerID=elecid_crystal.
towerId();
402 int strip=elecid_crystal.
stripId();
403 int xtal=elecid_crystal.
xtalId();
404 int channelID= 5*(strip-1) + xtal-1;
409 unsigned int MyPn0=pnpair.first;
410 unsigned int MyPn1=pnpair.second;
413 assert(channel <
nCrys);
420 for (
unsigned int i=0;
i< (*digiItr).size() ; ++
i ) {
423 adc[
i]=samp_crystal.adc() ;
424 adcG[
i]=samp_crystal.gainId();
426 if (
i==0) adcGain=
adcG[
i];
436 if(k<_presample-1) dsum1+=
adc[
k];
439 bl=dsum/((double)_presample);
440 bl1=dsum1/((double)_presample-1);
443 yrange[
k]=
adc[
k] - bl;
444 if(yrange[k] > val_max) {
445 val_max= yrange[
k]; samplemax=
k;
449 if(samplemax==4 || samplemax==5) {
450 val_max=val_max+bl-bl1;
452 yrange[
k]=yrange[
k]+bl-bl1;
460 pn0=allPNAmpl[MyPn0];
461 pn1=allPNAmpl[MyPn1];
471 EEDetId id_crystal(digiItr->id()) ;
474 phi = id_crystal.ix()-1 ;
475 eta = id_crystal.iy()-1 ;
482 int towerID=elecid_crystal.
towerId();
483 int channelID=elecid_crystal.
channelId()-1;
488 unsigned int MyPn0=pnpair.first;
489 unsigned int MyPn1=pnpair.second;
492 assert(channel <
nCrys);
499 for (
unsigned int i=0;
i< (*digiItr).size() ; ++
i ) {
502 adc[
i]=samp_crystal.adc() ;
503 adcG[
i]=samp_crystal.gainId();
505 if (
i==0) adcGain=
adcG[
i];
515 if(k<_presample-1) dsum1+=
adc[
k];
518 bl=dsum/((double)_presample);
519 bl1=dsum1/((double)_presample-1);
522 yrange[
k]=
adc[
k] - bl;
523 if(yrange[k] > val_max) {
524 val_max= yrange[
k]; samplemax=
k;
528 if(samplemax==4 || samplemax==5) {
529 val_max=val_max+bl-bl1;
531 yrange[
k]=yrange[
k]+bl-bl1;
539 pn0=allPNAmpl[MyPn0];
540 pn1=allPNAmpl[MyPn1];
556 unsigned int nCol=
colors.size();
562 cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
563 cout <<
"\t+=+ Analyzing laser data: getting per event +=+" << endl;
564 cout <<
"\t+=+ APD Amplitudes and ADC samples +=+"<< endl;
572 int ieta, iphi, channelID, towerID,
flag;
578 for (
unsigned int i=0;
i<nCol;
i++){
583 header[
i] =
new TTree(name1.str().c_str(),name1.str().c_str());
585 header[
i]->Branch(
"alpha", &alpha,
"alpha/D" );
586 header[
i]->Branch(
"beta", &beta,
"beta/D" );
587 header[
i]->Branch(
"iphi", &iphi,
"iphi/I" );
588 header[
i]->Branch(
"ieta", &ieta,
"ieta/I" );
590 header[
i]->Branch(
"towerID", &towerID,
"towerID/I" );
591 header[
i]->Branch(
"channelID", &channelID,
"channelID/I" );
593 header[
i]->SetBranchAddress(
"alpha", &alpha );
594 header[
i]->SetBranchAddress(
"beta", &beta );
595 header[
i]->SetBranchAddress(
"iphi", &iphi );
596 header[
i]->SetBranchAddress(
"ieta", &ieta );
598 header[
i]->SetBranchAddress(
"towerID", &towerID );
599 header[
i]->SetBranchAddress(
"channelID", &channelID );
605 APDtrees=
new TTree(name2.str().c_str(),name2.str().c_str());
616 APDtrees->Branch(
"flag", &flag,
"flag/I" );
627 APDtrees->SetBranchAddress(
"flag", &flag );
637 Double_t alphaRun, betaRun;
638 int ietaRun, iphiRun, channelIDRun, towerIDRun, dccIDRun, flagRun;
640 for(
unsigned int i=0;
i<nCol;
i++){
644 alphaTree[
i]=(TTree*)alphaFile->Get(name3.str().c_str());
645 alphaTree[
i]->SetBranchStatus(
"*", 0 );
646 alphaTree[
i]->SetBranchStatus(
"alpha", 1 );
647 alphaTree[
i]->SetBranchStatus(
"beta", 1 );
648 alphaTree[
i]->SetBranchStatus(
"iphi", 1 );
649 alphaTree[
i]->SetBranchStatus(
"ieta", 1 );
650 alphaTree[
i]->SetBranchStatus(
"dccID", 1 );
651 alphaTree[
i]->SetBranchStatus(
"towerID", 1 );
652 alphaTree[
i]->SetBranchStatus(
"channelID", 1 );
653 alphaTree[
i]->SetBranchStatus(
"flag", 1 );
655 alphaTree[
i]->SetBranchAddress(
"alpha", &alphaRun );
656 alphaTree[
i]->SetBranchAddress(
"beta", &betaRun );
657 alphaTree[
i]->SetBranchAddress(
"iphi", &iphiRun );
658 alphaTree[
i]->SetBranchAddress(
"ieta", &ietaRun );
659 alphaTree[
i]->SetBranchAddress(
"dccID", &dccIDRun );
660 alphaTree[
i]->SetBranchAddress(
"towerID", &towerIDRun );
661 alphaTree[
i]->SetBranchAddress(
"channelID", &channelIDRun );
662 alphaTree[
i]->SetBranchAddress(
"flag", &flagRun );
670 for (
unsigned int icol=0;icol<nCol;icol++){
674 cut <<
"color=="<<
colors.at(icol);
683 Long64_t nbytes = 0, nb = 0;
684 for (Long64_t jentry=0; jentry<
ADCtrees->GetEntriesFast();jentry++) {
685 nb =
ADCtrees->GetEntry(jentry); nbytes += nb;
692 for(
unsigned int i=0;
i<nCol;
i++){
699 alphaTree[iCol]->GetEntry(iCry);
706 channelID=channelIDRun;
721 chi2 = pslsfit -> doFit(&
adc[0]);
723 if( chi2 < 0. || chi2 == 102 || chi2 == 101 ) {
730 apdAmpl = pslsfit -> getAmpl();
753 system(del.str().c_str());
755 cout <<
"\t+=+ .................................................. done +=+" << endl;
756 cout <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
static XYCoord localCoord(int icr)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
unsigned int _lastsamplePN
static int crystal(CrysCoord ix, CrysCoord iy)
int xtalId() const
get the channel id
std::string eventHeaderCollection_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
int stripId() const
get the tower id
std::string refalphabeta_
#define DEFINE_FWK_MODULE(type)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
unsigned int _firstsample
unsigned int _firstsamplePN
std::vector< T >::const_iterator const_iterator
int towerId() const
get the tower id
const_iterator begin() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static std::pair< int, int > pn(int ilmmod)
std::vector< int > colors
std::string eventHeaderProducer_
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static std::pair< int, int > pn(int dee, int ilmod)
unsigned int _timingcutlow
std::string digiCollection_
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
int IsHeaderFilled[nColor]
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
unsigned int _timingcuthigh
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::string digiPNCollection_
const_iterator end() const
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
EcalPerEvtLaserAnalyzer(const edm::ParameterSet &iConfig)
unsigned int _presamplePN
T const * product() const
~EcalPerEvtLaserAnalyzer()
T const * product() const
const_iterator end() const
std::string digiProducer_
int IsThereDataADC[nColor]
int channelId() const
so far for EndCap only :
const_iterator begin() const