53 _nsamples( iConfig.getUntrackedParameter< unsigned int >(
"nSamples", 10 ) ),
54 _presample( iConfig.getUntrackedParameter< unsigned int >(
"nPresamples", 3 ) ),
55 _firstsample( iConfig.getUntrackedParameter< unsigned int >(
"firstSample", 1 ) ),
56 _lastsample( iConfig.getUntrackedParameter< unsigned int >(
"lastSample", 2 ) ),
57 _samplemin( iConfig.getUntrackedParameter< unsigned int >(
"sampleMin", 3 ) ),
58 _samplemax( iConfig.getUntrackedParameter< unsigned int >(
"sampleMax", 9 ) ),
59 _nsamplesPN( iConfig.getUntrackedParameter< unsigned int >(
"nSamplesPN", 50 ) ),
60 _presamplePN( iConfig.getUntrackedParameter< unsigned int >(
"nPresamplesPN", 6 ) ),
61 _firstsamplePN( iConfig.getUntrackedParameter< unsigned int >(
"firstSamplePN", 7 ) ),
62 _lastsamplePN( iConfig.getUntrackedParameter< unsigned int >(
"lastSamplePN", 8 ) ),
63 _timingcutlow( iConfig.getUntrackedParameter< unsigned int >(
"timingCutLow", 3 ) ),
64 _timingcuthigh( iConfig.getUntrackedParameter< unsigned int >(
"timingCutHigh", 7 ) ),
65 _niter( iConfig.getUntrackedParameter< unsigned int >(
"nIter", 3 ) ),
66 _fedid( iConfig.getUntrackedParameter< unsigned int >(
"fedID", 0 ) ),
67 _tower( iConfig.getUntrackedParameter< unsigned int >(
"tower", 1 ) ),
68 _channel( iConfig.getUntrackedParameter< unsigned int >(
"channel", 1 ) ),
69 _ecalPart( iConfig.getUntrackedParameter< std::
string >(
"ecalPart",
"EB" ) ),
73 IsFileCreated(0), nCh(0),
74 runType(-1), runNum(0), dccID(-1), lightside(2), doesRefFileExist(0),
75 ttMat(-1), peakMat(-1), peak(-1), evtMat(-1), colMat(-1)
123 stringstream namefile1;
124 namefile1 <<
resdir_<<
"/ADCSamples.root" ;
136 ADCtrees=
new TTree(name.str().c_str(),name.str().c_str());
177 DCCHeader=pDCCHeader.
product();
220 TheMapping = ecalmapping.
product();
222 std::cerr <<
"Error! can't get the product EcalMappingRcd"<< std::endl;
234 int fed = headerItr->fedId();
238 runType=headerItr->getRunType();
239 runNum=headerItr->getRunNumber();
240 event=headerItr->getLV1();
241 dccID=headerItr->getDccInTCCCommand();
242 fedID=headerItr->fedId();
254 stringstream namefile2;
266 test = fopen(namefile.str().c_str(),
"r");
270 matacqFile =
new TFile((namefile.str().c_str()));
290 colors.push_back( color );
291 cout <<
" new color found "<< color<<
" "<<
colors.size()<< endl;
315 unsigned int samplemax=0;
318 std::vector<double> allPNAmpl;
323 for (
int samId=0; samId < (*pnItr).size() ; samId++ ) {
324 pn[samId]=(*pnItr).sample(samId).adc();
331 bl=dsum/((double) _presamplePN);
334 ypnrange[
k]=
pn[
k] - bl;
336 if(ypnrange[k] > val_max) {
337 val_max= ypnrange[
k]; samplemax=
k;
341 chi2pn = pnfit -> doFit(samplemax,&ypnrange[0]);
343 if(chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
pnAmpl=0.;
344 else pnAmpl= pnfit -> getAmpl();
346 allPNAmpl.push_back(
pnAmpl);
379 EBDetId id_crystal(digiItr->id()) ;
382 int etaG = id_crystal.ieta() ;
383 int phiG = id_crystal.iphi() ;
389 etaL=LocalCoord.first ;
390 phiL=LocalCoord.second ;
401 int strip=elecid_crystal.
stripId();
402 int xtal=elecid_crystal.
xtalId();
403 int channelID= 5*(strip-1) + xtal-1;
408 unsigned int MyPn0=pnpair.first;
409 unsigned int MyPn1=pnpair.second;
412 assert(channel <
nCrys);
419 for (
unsigned int i=0;
i< (*digiItr).size() ; ++
i ) {
422 adc[
i]=samp_crystal.adc() ;
423 adcG[
i]=samp_crystal.gainId();
425 if (
i==0) adcGain=
adcG[
i];
435 if(k<_presample-1) dsum1+=
adc[
k];
438 bl=dsum/((double)_presample);
439 bl1=dsum1/((double)_presample-1);
442 yrange[
k]=
adc[
k] - bl;
443 if(yrange[k] > val_max) {
444 val_max= yrange[
k]; samplemax=
k;
448 if(samplemax==4 || samplemax==5) {
449 val_max=val_max+bl-bl1;
451 yrange[
k]=yrange[
k]+bl-bl1;
459 pn0=allPNAmpl[MyPn0];
460 pn1=allPNAmpl[MyPn1];
470 EEDetId id_crystal(digiItr->id()) ;
473 phi = id_crystal.ix()-1 ;
474 eta = id_crystal.iy()-1 ;
482 int channelID=elecid_crystal.
channelId()-1;
487 unsigned int MyPn0=pnpair.first;
488 unsigned int MyPn1=pnpair.second;
491 assert(channel <
nCrys);
498 for (
unsigned int i=0;
i< (*digiItr).size() ; ++
i ) {
501 adc[
i]=samp_crystal.adc() ;
502 adcG[
i]=samp_crystal.gainId();
504 if (
i==0) adcGain=
adcG[
i];
514 if(k<_presample-1) dsum1+=
adc[
k];
517 bl=dsum/((double)_presample);
518 bl1=dsum1/((double)_presample-1);
521 yrange[
k]=
adc[
k] - bl;
522 if(yrange[k] > val_max) {
523 val_max= yrange[
k]; samplemax=
k;
527 if(samplemax==4 || samplemax==5) {
528 val_max=val_max+bl-bl1;
530 yrange[
k]=yrange[
k]+bl-bl1;
538 pn0=allPNAmpl[MyPn0];
539 pn1=allPNAmpl[MyPn1];
555 unsigned int nCol=
colors.size();
561 cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
562 cout <<
"\t+=+ Analyzing laser data: getting per event +=+" << endl;
563 cout <<
"\t+=+ APD Amplitudes and ADC samples +=+"<< endl;
577 for (
unsigned int i=0;
i<nCol;
i++){
582 header[
i] =
new TTree(name1.str().c_str(),name1.str().c_str());
584 header[
i]->Branch(
"alpha", &alpha,
"alpha/D" );
585 header[
i]->Branch(
"beta", &beta,
"beta/D" );
586 header[
i]->Branch(
"iphi", &iphi,
"iphi/I" );
587 header[
i]->Branch(
"ieta", &ieta,
"ieta/I" );
589 header[
i]->Branch(
"towerID", &towerID,
"towerID/I" );
590 header[
i]->Branch(
"channelID", &channelID,
"channelID/I" );
592 header[
i]->SetBranchAddress(
"alpha", &alpha );
593 header[
i]->SetBranchAddress(
"beta", &beta );
594 header[
i]->SetBranchAddress(
"iphi", &iphi );
595 header[
i]->SetBranchAddress(
"ieta", &ieta );
597 header[
i]->SetBranchAddress(
"towerID", &towerID );
598 header[
i]->SetBranchAddress(
"channelID", &channelID );
604 APDtrees=
new TTree(name2.str().c_str(),name2.str().c_str());
615 APDtrees->Branch(
"flag", &flag,
"flag/I" );
626 APDtrees->SetBranchAddress(
"flag", &flag );
636 Double_t alphaRun, betaRun;
637 int ietaRun, iphiRun, channelIDRun, towerIDRun, dccIDRun, flagRun;
639 for(
unsigned int i=0;
i<nCol;
i++){
643 alphaTree[
i]=(TTree*)alphaFile->Get(name3.str().c_str());
644 alphaTree[
i]->SetBranchStatus(
"*", 0 );
645 alphaTree[
i]->SetBranchStatus(
"alpha", 1 );
646 alphaTree[
i]->SetBranchStatus(
"beta", 1 );
647 alphaTree[
i]->SetBranchStatus(
"iphi", 1 );
648 alphaTree[
i]->SetBranchStatus(
"ieta", 1 );
649 alphaTree[
i]->SetBranchStatus(
"dccID", 1 );
650 alphaTree[
i]->SetBranchStatus(
"towerID", 1 );
651 alphaTree[
i]->SetBranchStatus(
"channelID", 1 );
652 alphaTree[
i]->SetBranchStatus(
"flag", 1 );
654 alphaTree[
i]->SetBranchAddress(
"alpha", &alphaRun );
655 alphaTree[
i]->SetBranchAddress(
"beta", &betaRun );
656 alphaTree[
i]->SetBranchAddress(
"iphi", &iphiRun );
657 alphaTree[
i]->SetBranchAddress(
"ieta", &ietaRun );
658 alphaTree[
i]->SetBranchAddress(
"dccID", &dccIDRun );
659 alphaTree[
i]->SetBranchAddress(
"towerID", &towerIDRun );
660 alphaTree[
i]->SetBranchAddress(
"channelID", &channelIDRun );
661 alphaTree[
i]->SetBranchAddress(
"flag", &flagRun );
669 for (
unsigned int icol=0;icol<nCol;icol++){
673 cut <<
"color=="<<
colors.at(icol);
682 Long64_t nbytes = 0, nb = 0;
683 for (Long64_t jentry=0; jentry<
ADCtrees->GetEntriesFast();jentry++) {
684 nb =
ADCtrees->GetEntry(jentry); nbytes += nb;
691 for(
unsigned int i=0;
i<nCol;
i++){
698 alphaTree[iCol]->GetEntry(iCry);
705 channelID=channelIDRun;
720 chi2 = pslsfit -> doFit(&
adc[0]);
722 if( chi2 < 0. || chi2 == 102 || chi2 == 101 ) {
729 apdAmpl = pslsfit -> getAmpl();
752 system(del.str().c_str());
754 cout <<
"\t+=+ .................................................. done +=+" << endl;
755 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< EcalDCCHeaderBlock >::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
T const * product() const
~EcalPerEvtLaserAnalyzer()
const_iterator end() const
std::string digiProducer_
EcalLogicID towerID(EcalElectronicsId const &)
int IsThereDataADC[nColor]
int channelId() const
so far for EndCap only :
const_iterator begin() const