51 _nsamples(iConfig.getUntrackedParameter<unsigned
int>(
"nSamples", 10)),
52 _presample(iConfig.getUntrackedParameter<unsigned
int>(
"nPresamples", 3)),
53 _firstsample(iConfig.getUntrackedParameter<unsigned
int>(
"firstSample", 1)),
54 _lastsample(iConfig.getUntrackedParameter<unsigned
int>(
"lastSample", 2)),
55 _samplemin(iConfig.getUntrackedParameter<unsigned
int>(
"sampleMin", 3)),
56 _samplemax(iConfig.getUntrackedParameter<unsigned
int>(
"sampleMax", 9)),
57 _nsamplesPN(iConfig.getUntrackedParameter<unsigned
int>(
"nSamplesPN", 50)),
58 _presamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"nPresamplesPN", 6)),
59 _firstsamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"firstSamplePN", 7)),
60 _lastsamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"lastSamplePN", 8)),
61 _timingcutlow(iConfig.getUntrackedParameter<unsigned
int>(
"timingCutLow", 3)),
62 _timingcuthigh(iConfig.getUntrackedParameter<unsigned
int>(
"timingCutHigh", 7)),
63 _niter(iConfig.getUntrackedParameter<unsigned
int>(
"nIter", 3)),
64 _fedid(iConfig.getUntrackedParameter<unsigned
int>(
"fedID", 0)),
65 _tower(iConfig.getUntrackedParameter<unsigned
int>(
"tower", 1)),
66 _channel(iConfig.getUntrackedParameter<unsigned
int>(
"channel", 1)),
67 _ecalPart(iConfig.getUntrackedParameter<
std::
string>(
"ecalPart",
"EB")),
123 stringstream namefile1;
124 namefile1 <<
resdir_ <<
"/ADCSamples.root";
135 ADCtrees =
new TTree(name.str().c_str(), name.str().c_str());
174 DCCHeader = pDCCHeader.
product();
216 TheMapping = ecalmapping.
product();
218 std::cerr <<
"Error! can't get the product EcalMappingRcd" << std::endl;
229 int fed = headerItr->fedId();
234 runType = headerItr->getRunType();
235 runNum = headerItr->getRunNumber();
236 event = headerItr->getLV1();
237 dccID = headerItr->getDccInTCCCommand();
238 fedID = headerItr->fedId();
251 stringstream namefile2;
257 stringstream namefile;
263 test = fopen(namefile.str().c_str(),
"r");
268 matacqFile =
new TFile((namefile.str().c_str()));
286 if (iter ==
colors.end()) {
288 cout <<
" new color found " << color <<
" " <<
colors.size() << endl;
311 unsigned int samplemax = 0;
314 std::vector<double> allPNAmpl;
319 for (
int samId = 0; samId < (*pnItr).size(); samId++) {
320 pn[samId] = (*pnItr).sample(samId).adc();
326 bl = dsum / ((double)_presamplePN);
329 ypnrange[
k] =
pn[
k] - bl;
331 if (ypnrange[k] > val_max) {
332 val_max = ypnrange[
k];
337 chi2pn = pnfit->
doFit(samplemax, &ypnrange[0]);
339 if (chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
344 allPNAmpl.push_back(
pnAmpl);
376 EBDetId id_crystal(digiItr->id());
379 int etaG = id_crystal.ieta();
380 int phiG = id_crystal.iphi();
386 etaL = LocalCoord.first;
387 phiL = LocalCoord.second;
399 int xtal = elecid_crystal.
xtalId();
400 int channelID = 5 * (strip - 1) + xtal - 1;
405 unsigned int MyPn0 = pnpair.first;
406 unsigned int MyPn1 = pnpair.second;
409 assert(channel <
nCrys);
418 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
421 adc[
i] = samp_crystal.adc();
422 adcG[
i] = samp_crystal.gainId();
429 if (adc[i] > adcmax) {
434 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
436 if (k < _presample - 1)
440 bl = dsum / ((double)_presample);
441 bl1 = dsum1 / ((double)_presample - 1);
443 for (val_max = 0., k = 0; k <
_nsamples; k++) {
444 yrange[
k] =
adc[
k] - bl;
445 if (yrange[k] > val_max) {
451 if (samplemax == 4 || samplemax == 5) {
452 val_max = val_max + bl - bl1;
454 yrange[
k] = yrange[
k] + bl - bl1;
458 for (
unsigned int k = 0; k <
_nsamples; k++) {
462 pn0 = allPNAmpl[MyPn0];
463 pn1 = allPNAmpl[MyPn1];
473 EEDetId id_crystal(digiItr->id());
476 phi = id_crystal.ix() - 1;
477 eta = id_crystal.iy() - 1;
485 int channelID = elecid_crystal.
channelId() - 1;
490 unsigned int MyPn0 = pnpair.first;
491 unsigned int MyPn1 = pnpair.second;
494 assert(channel <
nCrys);
503 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
506 adc[
i] = samp_crystal.adc();
507 adcG[
i] = samp_crystal.gainId();
514 if (adc[i] > adcmax) {
519 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
521 if (k < _presample - 1)
525 bl = dsum / ((double)_presample);
526 bl1 = dsum1 / ((double)_presample - 1);
528 for (val_max = 0., k = 0; k <
_nsamples; k++) {
529 yrange[
k] =
adc[
k] - bl;
530 if (yrange[k] > val_max) {
536 if (samplemax == 4 || samplemax == 5) {
537 val_max = val_max + bl - bl1;
539 yrange[
k] = yrange[
k] + bl - bl1;
543 for (
unsigned int k = 0; k <
_nsamples; k++) {
547 pn0 = allPNAmpl[MyPn0];
548 pn1 = allPNAmpl[MyPn1];
562 unsigned int nCol =
colors.size();
566 cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << endl;
567 cout <<
"\t+=+ Analyzing laser data: getting per event +=+" << endl;
568 cout <<
"\t+=+ APD Amplitudes and ADC samples +=+" << endl;
580 for (
unsigned int i = 0;
i < nCol;
i++) {
582 name1 <<
"headerCol" <<
colors[
i];
584 header[
i] =
new TTree(name1.str().c_str(), name1.str().c_str());
586 header[
i]->Branch(
"alpha", &alpha,
"alpha/D");
587 header[
i]->Branch(
"beta", &beta,
"beta/D");
588 header[
i]->Branch(
"iphi", &iphi,
"iphi/I");
589 header[
i]->Branch(
"ieta", &ieta,
"ieta/I");
591 header[
i]->Branch(
"towerID", &towerID,
"towerID/I");
592 header[
i]->Branch(
"channelID", &channelID,
"channelID/I");
594 header[
i]->SetBranchAddress(
"alpha", &alpha);
595 header[
i]->SetBranchAddress(
"beta", &beta);
596 header[
i]->SetBranchAddress(
"iphi", &iphi);
597 header[
i]->SetBranchAddress(
"ieta", &ieta);
599 header[
i]->SetBranchAddress(
"towerID", &towerID);
600 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);
636 Double_t alphaRun, betaRun;
637 int ietaRun, iphiRun, channelIDRun, towerIDRun, dccIDRun, flagRun;
639 for (
unsigned int i = 0;
i < nCol;
i++) {
641 name3 <<
"ABCol" <<
i;
642 alphaTree[
i] = (TTree*)alphaFile->Get(name3.str().c_str());
643 alphaTree[
i]->SetBranchStatus(
"*",
false);
644 alphaTree[
i]->SetBranchStatus(
"alpha",
true);
645 alphaTree[
i]->SetBranchStatus(
"beta",
true);
646 alphaTree[
i]->SetBranchStatus(
"iphi",
true);
647 alphaTree[
i]->SetBranchStatus(
"ieta",
true);
648 alphaTree[
i]->SetBranchStatus(
"dccID",
true);
649 alphaTree[
i]->SetBranchStatus(
"towerID",
true);
650 alphaTree[
i]->SetBranchStatus(
"channelID",
true);
651 alphaTree[
i]->SetBranchStatus(
"flag",
true);
653 alphaTree[
i]->SetBranchAddress(
"alpha", &alphaRun);
654 alphaTree[
i]->SetBranchAddress(
"beta", &betaRun);
655 alphaTree[
i]->SetBranchAddress(
"iphi", &iphiRun);
656 alphaTree[
i]->SetBranchAddress(
"ieta", &ietaRun);
657 alphaTree[
i]->SetBranchAddress(
"dccID", &dccIDRun);
658 alphaTree[
i]->SetBranchAddress(
"towerID", &towerIDRun);
659 alphaTree[
i]->SetBranchAddress(
"channelID", &channelIDRun);
660 alphaTree[
i]->SetBranchAddress(
"flag", &flagRun);
667 for (
unsigned int icol = 0; icol < nCol; icol++) {
670 cut <<
"color==" <<
colors.at(icol);
671 if (
ADCtrees->GetEntries(cut.str().c_str()) < 10)
678 Long64_t nbytes = 0, nb = 0;
679 for (Long64_t jentry = 0; jentry <
ADCtrees->GetEntriesFast(); jentry++) {
687 unsigned int iCol = 0;
688 for (
unsigned int i = 0;
i < nCol;
i++) {
695 alphaTree[iCol]->GetEntry(iCry);
700 towerID = towerIDRun;
701 channelID = channelIDRun;
717 if (chi2 < 0. || chi2 == 102 || chi2 == 101) {
740 system(del.str().c_str());
742 cout <<
"\t+=+ .................................................. done +=+" << endl;
743 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_
int stripId() const
get the tower id
std::string refalphabeta_
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)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
static std::pair< int, int > pn(int ilmmod)
std::string eventHeaderProducer_
~EcalPerEvtLaserAnalyzer() override
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
#define DEFINE_FWK_MODULE(type)
std::string digiCollection_
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
int IsHeaderFilled[nColor]
unsigned int _timingcuthigh
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual void init(int, int, int, int, double, double)
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
virtual double doFit(double *)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const_iterator end() const
std::string digiProducer_
double doFit(int, double *)
EcalLogicID towerID(EcalElectronicsId const &)
alpha
zGenParticlesMatch = cms.InputTag(""),
int IsThereDataADC[nColor]
T const * product() const
int channelId() const
so far for EndCap only :
const_iterator begin() const