39 eventHeaderCollection_(iConfig.getParameter<std::
string>(
"eventHeaderCollection")),
40 eventHeaderProducer_(iConfig.getParameter<std::
string>(
"eventHeaderProducer")),
41 digiCollection_(iConfig.getParameter<std::
string>(
"digiCollection")),
42 digiProducer_(iConfig.getParameter<std::
string>(
"digiProducer")),
43 digiPNCollection_(iConfig.getParameter<std::
string>(
"digiPNCollection")),
48 _nsamples(iConfig.getUntrackedParameter<unsigned int>(
"nSamples", 10)),
49 _presample(iConfig.getUntrackedParameter<unsigned int>(
"nPresamples", 3)),
50 _firstsample(iConfig.getUntrackedParameter<unsigned int>(
"firstSample", 1)),
51 _lastsample(iConfig.getUntrackedParameter<unsigned int>(
"lastSample", 2)),
52 _nsamplesPN(iConfig.getUntrackedParameter<unsigned int>(
"nSamplesPN", 50)),
53 _presamplePN(iConfig.getUntrackedParameter<unsigned int>(
"nPresamplesPN", 6)),
54 _firstsamplePN(iConfig.getUntrackedParameter<unsigned int>(
"firstSamplePN", 7)),
55 _lastsamplePN(iConfig.getUntrackedParameter<unsigned int>(
"lastSamplePN", 8)),
56 _timingcutlow(iConfig.getUntrackedParameter<unsigned int>(
"timingCutLow", 3)),
57 _timingcuthigh(iConfig.getUntrackedParameter<unsigned int>(
"timingCutHigh", 7)),
58 _niter(iConfig.getUntrackedParameter<unsigned int>(
"nIter", 3)),
59 _fedid(iConfig.getUntrackedParameter<unsigned int>(
"fedID", 0)),
60 _tower(iConfig.getUntrackedParameter<unsigned int>(
"tower", 1)),
61 _channel(iConfig.getUntrackedParameter<unsigned int>(
"channel", 1)),
62 _ecalPart(iConfig.getUntrackedParameter<std::
string>(
"ecalPart",
"EB")),
63 resdir_(iConfig.getUntrackedParameter<std::
string>(
"resDir")),
64 refalphabeta_(iConfig.getUntrackedParameter<std::
string>(
"refAlphaBeta")),
109 stringstream namefile1;
110 namefile1 <<
resdir_ <<
"/ADCSamples.root";
121 ADCtrees =
new TTree(name.str().c_str(), name.str().c_str());
161 DCCHeader = pDCCHeader.
product();
206 int fed = headerItr->fedId();
211 runType = headerItr->getRunType();
212 runNum = headerItr->getRunNumber();
213 event = headerItr->getLV1();
214 dccID = headerItr->getDccInTCCCommand();
215 fedID = headerItr->fedId();
228 stringstream namefile2;
234 stringstream namefile;
240 test = fopen(namefile.str().c_str(),
"r");
245 matacqFile =
new TFile((namefile.str().c_str()));
263 if (iter ==
colors.end()) {
288 unsigned int samplemax = 0;
291 std::vector<double> allPNAmpl;
296 for (
int samId = 0; samId < (*pnItr).size(); samId++) {
297 pn[samId] = (*pnItr).sample(samId).adc();
303 bl = dsum / ((double)_presamplePN);
306 ypnrange[
k] =
pn[
k] - bl;
308 if (ypnrange[k] > val_max) {
309 val_max = ypnrange[
k];
314 chi2pn = pnfit->
doFit(samplemax, &ypnrange[0]);
316 if (chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
321 allPNAmpl.push_back(
pnAmpl);
353 EBDetId id_crystal(digiItr->id());
356 int etaG = id_crystal.ieta();
357 int phiG = id_crystal.iphi();
363 etaL = LocalCoord.first;
364 phiL = LocalCoord.second;
376 int xtal = elecid_crystal.
xtalId();
377 int channelID = 5 * (strip - 1) + xtal - 1;
382 unsigned int MyPn0 = pnpair.first;
383 unsigned int MyPn1 = pnpair.second;
395 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
398 adc[
i] = samp_crystal.adc();
399 adcG[
i] = samp_crystal.gainId();
406 if (adc[i] > adcmax) {
411 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
413 if (k < _presample - 1)
417 bl = dsum / ((double)_presample);
418 bl1 = dsum1 / ((double)_presample - 1);
420 for (val_max = 0., k = 0; k <
_nsamples; k++) {
421 yrange[
k] =
adc[
k] - bl;
422 if (yrange[k] > val_max) {
428 if (samplemax == 4 || samplemax == 5) {
429 val_max = val_max + bl - bl1;
431 yrange[
k] = yrange[
k] + bl - bl1;
435 for (
unsigned int k = 0; k <
_nsamples; k++) {
439 pn0 = allPNAmpl[MyPn0];
440 pn1 = allPNAmpl[MyPn1];
450 EEDetId id_crystal(digiItr->id());
453 phi = id_crystal.ix() - 1;
454 eta = id_crystal.iy() - 1;
462 int channelID = elecid_crystal.
channelId() - 1;
467 unsigned int MyPn0 = pnpair.first;
468 unsigned int MyPn1 = pnpair.second;
480 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
483 adc[
i] = samp_crystal.adc();
484 adcG[
i] = samp_crystal.gainId();
491 if (adc[i] > adcmax) {
496 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
498 if (k < _presample - 1)
502 bl = dsum / ((double)_presample);
503 bl1 = dsum1 / ((double)_presample - 1);
505 for (val_max = 0., k = 0; k <
_nsamples; k++) {
506 yrange[
k] =
adc[
k] - bl;
507 if (yrange[k] > val_max) {
513 if (samplemax == 4 || samplemax == 5) {
514 val_max = val_max + bl - bl1;
516 yrange[
k] = yrange[
k] + bl - bl1;
520 for (
unsigned int k = 0; k <
_nsamples; k++) {
524 pn0 = allPNAmpl[MyPn0];
525 pn1 = allPNAmpl[MyPn1];
539 unsigned int nCol =
colors.size();
544 <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
546 <<
"\t+=+ Analyzing laser data: getting per event +=+";
548 <<
"\t+=+ APD Amplitudes and ADC samples +=+";
556 int ieta, iphi, channelID,
towerID, flag;
561 for (
unsigned int i = 0;
i < nCol;
i++) {
563 name1 <<
"headerCol" <<
colors[
i];
565 header[
i] =
new TTree(name1.str().c_str(), name1.str().c_str());
567 header[
i]->Branch(
"alpha", &alpha,
"alpha/D");
568 header[
i]->Branch(
"beta", &beta,
"beta/D");
569 header[
i]->Branch(
"iphi", &iphi,
"iphi/I");
570 header[
i]->Branch(
"ieta", &ieta,
"ieta/I");
572 header[
i]->Branch(
"towerID", &towerID,
"towerID/I");
573 header[
i]->Branch(
"channelID", &channelID,
"channelID/I");
575 header[
i]->SetBranchAddress(
"alpha", &alpha);
576 header[
i]->SetBranchAddress(
"beta", &beta);
577 header[
i]->SetBranchAddress(
"iphi", &iphi);
578 header[
i]->SetBranchAddress(
"ieta", &ieta);
580 header[
i]->SetBranchAddress(
"towerID", &towerID);
581 header[
i]->SetBranchAddress(
"channelID", &channelID);
586 APDtrees =
new TTree(name2.str().c_str(), name2.str().c_str());
597 APDtrees->Branch(
"flag", &flag,
"flag/I");
608 APDtrees->SetBranchAddress(
"flag", &flag);
617 Double_t alphaRun, betaRun;
618 int ietaRun, iphiRun, channelIDRun, towerIDRun, dccIDRun, flagRun;
620 for (
unsigned int i = 0;
i < nCol;
i++) {
622 name3 <<
"ABCol" <<
i;
623 alphaTree[
i] = (TTree*)alphaFile->Get(name3.str().c_str());
624 alphaTree[
i]->SetBranchStatus(
"*",
false);
625 alphaTree[
i]->SetBranchStatus(
"alpha",
true);
626 alphaTree[
i]->SetBranchStatus(
"beta",
true);
627 alphaTree[
i]->SetBranchStatus(
"iphi",
true);
628 alphaTree[
i]->SetBranchStatus(
"ieta",
true);
629 alphaTree[
i]->SetBranchStatus(
"dccID",
true);
630 alphaTree[
i]->SetBranchStatus(
"towerID",
true);
631 alphaTree[
i]->SetBranchStatus(
"channelID",
true);
632 alphaTree[
i]->SetBranchStatus(
"flag",
true);
634 alphaTree[
i]->SetBranchAddress(
"alpha", &alphaRun);
635 alphaTree[
i]->SetBranchAddress(
"beta", &betaRun);
636 alphaTree[
i]->SetBranchAddress(
"iphi", &iphiRun);
637 alphaTree[
i]->SetBranchAddress(
"ieta", &ietaRun);
638 alphaTree[
i]->SetBranchAddress(
"dccID", &dccIDRun);
639 alphaTree[
i]->SetBranchAddress(
"towerID", &towerIDRun);
640 alphaTree[
i]->SetBranchAddress(
"channelID", &channelIDRun);
641 alphaTree[
i]->SetBranchAddress(
"flag", &flagRun);
648 for (
unsigned int icol = 0; icol < nCol; icol++) {
651 cut <<
"color==" <<
colors.at(icol);
652 if (
ADCtrees->GetEntries(cut.str().c_str()) < 10)
659 Long64_t nbytes = 0, nb = 0;
660 for (Long64_t jentry = 0; jentry <
ADCtrees->GetEntriesFast(); jentry++) {
668 unsigned int iCol = 0;
669 for (
unsigned int i = 0;
i < nCol;
i++) {
676 alphaTree[iCol]->GetEntry(iCry);
681 towerID = towerIDRun;
682 channelID = channelIDRun;
698 if (chi2 < 0. || chi2 == 102 || chi2 == 101) {
721 system(del.str().c_str());
724 <<
"\t+=+ .................................................. done +=+";
726 <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
const std::string eventHeaderCollection_
Log< level::Info, true > LogVerbatim
static XYCoord localCoord(int icr)
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
const unsigned int _tower
const edm::EventSetup & c
static int crystal(CrysCoord ix, CrysCoord iy)
int xtalId() const
get the channel id
const std::string digiCollection_
edm::EDGetTokenT< EBDigiCollection > ebDigiToken_
const unsigned int _firstsample
int stripId() const
get the tower id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
std::vector< T >::const_iterator const_iterator
const unsigned int _presamplePN
const unsigned int _timingcuthigh
int towerId() const
get the tower id
const_iterator begin() const
The iterator returned can not safely be used across threads.
Log< level::Error, false > LogError
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::vector< int > colors
const unsigned int _presample
bool getData(T &iHolder) const
~EcalPerEvtLaserAnalyzer() override
const std::string _ecalPart
static std::pair< int, int > pn(int dee, int ilmod)
const unsigned int _lastsample
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
int IsHeaderFilled[nColor]
const unsigned int _channel
const unsigned int _timingcutlow
const unsigned int _firstsamplePN
const std::string digiPNCollection_
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
virtual void init(int, int, int, int, double, double)
const unsigned int _nsamples
const_iterator end() const
const std::string digiProducer_
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
EcalPerEvtLaserAnalyzer(const edm::ParameterSet &iConfig)
T const * product() const
const std::string resdir_
virtual double doFit(double *)
const unsigned int _niter
const unsigned int _nsamplesPN
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const_iterator end() const
const std::string refalphabeta_
edm::EDGetTokenT< EEDigiCollection > eeDigiToken_
const edm::EDGetTokenT< EcalRawDataCollection > rawDataToken_
double doFit(int, double *)
EcalLogicID towerID(EcalElectronicsId const &)
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > mappingToken_
const unsigned int _lastsamplePN
int IsThereDataADC[nColor]
int channelId() const
so far for EndCap only :
const_iterator begin() const
const edm::EDGetTokenT< EcalPnDiodeDigiCollection > pnDiodeDigiToken_