49 eventHeaderCollection_(iConfig.getParameter<
std::
string>(
"eventHeaderCollection")),
50 eventHeaderProducer_(iConfig.getParameter<
std::
string>(
"eventHeaderProducer")),
51 digiCollection_(iConfig.getParameter<
std::
string>(
"digiCollection")),
52 digiProducer_(iConfig.getParameter<
std::
string>(
"digiProducer")),
53 digiPNCollection_(iConfig.getParameter<
std::
string>(
"digiPNCollection")),
58 _nsamples(iConfig.getUntrackedParameter<unsigned
int>(
"nSamples", 10)),
59 _presample(iConfig.getUntrackedParameter<unsigned
int>(
"nPresamples", 2)),
60 _firstsample(iConfig.getUntrackedParameter<unsigned
int>(
"firstSample", 1)),
61 _lastsample(iConfig.getUntrackedParameter<unsigned
int>(
"lastSample", 2)),
62 _nsamplesPN(iConfig.getUntrackedParameter<unsigned
int>(
"nSamplesPN", 50)),
63 _presamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"nPresamplesPN", 6)),
64 _firstsamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"firstSamplePN", 7)),
65 _lastsamplePN(iConfig.getUntrackedParameter<unsigned
int>(
"lastSamplePN", 8)),
66 _timingcutlow(iConfig.getUntrackedParameter<unsigned
int>(
"timingCutLow", 2)),
67 _timingcuthigh(iConfig.getUntrackedParameter<unsigned
int>(
"timingCutHigh", 9)),
68 _timingquallow(iConfig.getUntrackedParameter<unsigned
int>(
"timingQualLow", 3)),
69 _timingqualhigh(iConfig.getUntrackedParameter<unsigned
int>(
"timingQualHigh", 8)),
70 _ratiomincutlow(iConfig.getUntrackedParameter<double>(
"ratioMinCutLow", 0.4)),
71 _ratiomincuthigh(iConfig.getUntrackedParameter<double>(
"ratioMinCutHigh", 0.95)),
72 _ratiomaxcutlow(iConfig.getUntrackedParameter<double>(
"ratioMaxCutLow", 0.8)),
73 _presamplecut(iConfig.getUntrackedParameter<double>(
"presampleCut", 5.0)),
74 _niter(iConfig.getUntrackedParameter<unsigned
int>(
"nIter", 3)),
75 _fitab(iConfig.getUntrackedParameter<
bool>(
"fitAB",
false)),
76 _alpha(iConfig.getUntrackedParameter<double>(
"alpha", 1.5076494)),
77 _beta(iConfig.getUntrackedParameter<double>(
"beta", 1.5136036)),
78 _nevtmax(iConfig.getUntrackedParameter<unsigned
int>(
"nEvtMax", 200)),
79 _noise(iConfig.getUntrackedParameter<double>(
"noise", 2.0)),
80 _chi2cut(iConfig.getUntrackedParameter<double>(
"chi2cut", 10.0)),
81 _ecalPart(iConfig.getUntrackedParameter<
std::
string>(
"ecalPart",
"EB")),
82 _docorpn(iConfig.getUntrackedParameter<
bool>(
"doCorPN",
false)),
83 _fedid(iConfig.getUntrackedParameter<
int>(
"fedID", -999)),
84 _saveallevents(iConfig.getUntrackedParameter<
bool>(
"saveAllEvents",
false)),
85 _qualpercent(iConfig.getUntrackedParameter<double>(
"qualPercent", 0.2)),
86 _debug(iConfig.getUntrackedParameter<
int>(
"debug", 0)),
87 resdir_(iConfig.getUntrackedParameter<
std::
string>(
"resDir")),
88 pncorfile_(iConfig.getUntrackedParameter<
std::
string>(
"pnCorFile")),
138 for (
unsigned int j = 0;
j <
nCrys;
j++) {
150 for (
unsigned int j = 0;
j <
nMod;
j++) {
206 ADCfile +=
"/APDSamplesLaser.root";
209 APDfile +=
"/APDPNLaserAllEvents.root";
213 for (
unsigned int i = 0;
i <
nCrys;
i++) {
214 std::stringstream
name;
215 name <<
"ADCTree" <<
i + 1;
252 std::stringstream nameabinitfile;
253 nameabinitfile <<
resdir_ <<
"/ABInit.root";
256 std::stringstream nameabfile;
257 nameabfile <<
resdir_ <<
"/AB.root";
265 if (
test ==
nullptr) {
271 TFile* fAB =
nullptr;
272 TTree* ABInit =
nullptr;
274 fAB =
new TFile(nameabinitfile.str().c_str());
277 ABInit = (TTree*)fAB->Get(
"ABCol0");
297 std::stringstream nameapdfile;
298 nameapdfile <<
resdir_ <<
"/APDPN_LASER.root";
320 DCCHeader = pDCCHeader.
product();
343 edm::LogError(
"cfg_error") <<
" Wrong ecalPart in cfg file ";
368 int fed = headerItr->fedId();
372 runType = headerItr->getRunType();
373 runNum = headerItr->getRunNumber();
374 event = headerItr->getLV1();
376 dccID = headerItr->getDccInTCCCommand();
377 fedID = headerItr->fedId();
399 if (iter ==
colors.end()) {
422 unsigned int samplemax = 0;
425 std::map<int, std::vector<double> > allPNAmpl;
426 std::map<int, std::vector<double> > allPNGain;
435 <<
"-- debug -- Inside PNDigi - pnID=" << pnDetId.
iPnId() <<
", dccID=" << pnDetId.
iDCCId();
445 for (
int samId = 0; samId < (*pnItr).size(); samId++) {
446 pn[samId] = (*pnItr).sample(samId).adc();
447 pnG[samId] = (*pnItr).sample(samId).gainId();
463 if (chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
480 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"-- debug -- Inside PNDigi - PNampl=" <<
pnAmpl <<
", PNgain=" << pnGain;
497 EBDetId id_crystal(digiItr->id());
501 int etaG = id_crystal.ieta();
502 int phiG = id_crystal.iphi();
506 int etaL = LocalCoord.first;
507 int phiL = LocalCoord.second;
510 int xtal = elecid_crystal.
xtalId();
518 unsigned int MyPn0 = pnpair.first;
519 unsigned int MyPn1 = pnpair.second;
529 <<
"-- debug -- Inside EBDigi - towerID:" <<
towerID <<
" channelID:" <<
channelID <<
" module:" <<
module 530 <<
" modules:" <<
modules.size();
537 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
539 adc[
i] = samp_crystal.adc();
540 adcG[
i] = samp_crystal.gainId();
562 int mem0 =
Mem->
Mem(lmr, 0);
563 int mem1 =
Mem->
Mem(lmr, 1);
565 if (allPNAmpl[mem0].
size() > MyPn0)
566 pn0 = allPNAmpl[mem0][MyPn0];
569 if (allPNAmpl[mem1].
size() > MyPn1)
570 pn1 = allPNAmpl[mem1][MyPn1];
601 EEDetId id_crystal(digiItr->id());
605 int etaG = id_crystal.iy();
606 int phiG = id_crystal.ix();
608 int iX = (phiG - 1) / 5 + 1;
609 int iY = (etaG - 1) / 5 + 1;
622 unsigned int MyPn0 = pnpair.first;
623 unsigned int MyPn1 = pnpair.second;
633 setGeomEE(etaG, phiG, iX, iY,
iZ,
module,
tower, ch, apdRefTT, channel, lmr);
637 <<
"-- debug -- Inside EEDigi - towerID:" <<
towerID <<
" channelID:" <<
channelID <<
" module:" <<
module 638 <<
" modules:" <<
modules.size();
643 if ((*digiItr).size() > 10)
644 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"SAMPLES SIZE > 10!" << (*digiItr).size();
648 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
650 adc[
i] = samp_crystal.adc();
651 adcG[
i] = samp_crystal.gainId();
674 int mem0 =
Mem->
Mem(lmr, 0);
675 int mem1 =
Mem->
Mem(lmr, 1);
677 if (allPNAmpl[mem0].
size() > MyPn0)
678 pn0 = allPNAmpl[mem0][MyPn0];
681 if (allPNAmpl[mem1].
size() > MyPn1)
682 pn1 = allPNAmpl[mem1][MyPn1];
738 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
739 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+ Analyzing data: getting (alpha, beta) +=+";
740 TFile* fAB =
nullptr;
741 TTree* ABInit =
nullptr;
746 ABInit = (TTree*)fAB->Get(
"ABCol0");
749 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+ .................................... done +=+";
750 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
758 std::stringstream del;
760 system(del.str().c_str());
768 double BadGainEvtPercentage = 0.0;
769 double BadTimingEvtPercentage = 0.0;
771 int nChanBadGain = 0;
772 int nChanBadTiming = 0;
774 for (
unsigned int i = 0;
i <
nCrys;
i++) {
789 double BadGainChanPercentage = double(nChanBadGain) / double(
nCrys);
790 double BadTimingChanPercentage = double(nChanBadTiming) / double(
nCrys);
800 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
801 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+ Analyzing laser data: getting APD, PN, APD/PN, PN/PN +=+";
804 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+ ............................ WARNING! APD GAIN WAS NOT 1 +=+";
806 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+ ............................ WARNING! TIMING WAS BAD +=+";
812 for (
unsigned int i = 0;
i <
nCrys;
i++) {
813 std::stringstream
name;
814 name <<
"APDTree" <<
i + 1;
855 for (
unsigned int iref = 0; iref <
nRefChan; iref++) {
856 for (
unsigned int imod = 0; imod <
nMod; imod++) {
859 std::stringstream nameref;
860 nameref <<
"refAPDTree" << imod <<
"_" << iref;
862 RefAPDtrees[iref][jmod] =
new TTree(nameref.str().c_str(), nameref.str().c_str());
881 unsigned int nCol =
colors.size();
886 for (
unsigned int iM = 0; iM <
nMod; iM++) {
887 unsigned int iMod =
modules[iM] - 1;
889 for (
unsigned int ich = 0; ich <
nPNPerMod; ich++) {
890 for (
unsigned int icol = 0; icol < nCol; icol++) {
903 for (
unsigned int iCry = 0; iCry <
nCrys; iCry++) {
904 for (
unsigned int icol = 0; icol < nCol; icol++) {
910 std::stringstream
cut;
912 if (
ADCtrees[iCry]->GetEntries(
cut.str().c_str()) < 10)
916 unsigned int iMod =
iModule[iCry] - 1;
922 for (Long64_t jentry = 0; jentry <
ADCtrees[iCry]->GetEntriesFast(); jentry++) {
927 unsigned int iCol = 0;
928 for (
unsigned int i = 0;
i < nCol;
i++) {
978 if (pn0 < 10 && pn1 > 10) {
980 }
else if (pn1 < 10 && pn0 > 10) {
983 pnmean = 0.5 * (
pn0 +
pn1);
992 for (
unsigned int ichan = 0; ichan <
nPNPerMod; ichan++) {
1013 for (
unsigned int ir = 0; ir <
nRefChan; ir++) {
1033 std::stringstream del;
1035 system(del.str().c_str());
1042 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
1043 std::stringstream nametree;
1044 nametree <<
"APDCol" <<
colors[iColor];
1045 std::stringstream nametree2;
1046 nametree2 <<
"PNCol" <<
colors[iColor];
1048 restrees[iColor] =
new TTree(nametree.str().c_str(), nametree.str().c_str());
1049 respntrees[iColor] =
new TTree(nametree2.str().c_str(), nametree2.str().c_str());
1058 restrees[iColor]->Branch(
"APD", &
APD,
"APD[6]/D");
1103 for (
unsigned int iM = 0; iM <
nMod; iM++) {
1104 unsigned int iMod =
modules[iM] - 1;
1106 for (
unsigned int ich = 0; ich <
nPNPerMod; ich++) {
1107 for (
unsigned int icol = 0; icol < nCol; icol++) {
1116 for (
unsigned int imod = 0; imod <
nMod; imod++) {
1127 for (
unsigned int iCry = 0; iCry <
nCrys; iCry++) {
1128 unsigned int iMod =
iModule[iCry] - 1;
1133 for (
unsigned int iCol = 0; iCol < nCol; iCol++) {
1134 std::vector<double> lowcut;
1135 std::vector<double> highcut;
1144 lowcut.push_back(cutMin);
1145 highcut.push_back(cutMax);
1149 lowcut.push_back(cutMin);
1150 highcut.push_back(cutMax);
1170 for (Long64_t jentry = 0; jentry <
APDtrees[iCry]->GetEntriesFast(); jentry++) {
1174 if (pn0 < 10 && pn1 > 10) {
1176 }
else if (pn1 < 10 && pn0 > 10) {
1179 pnmean = 0.5 * (
pn0 +
pn1);
1184 unsigned int iCol = 0;
1185 for (
unsigned int i = 0;
i < nCol;
i++) {
1196 for (
unsigned int ichan = 0; ichan <
nPNPerMod; ichan++) {
1205 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"-- debug test -- Last Loop event:" <<
event <<
" apdAmpl:" <<
apdAmpl;
1209 for (
unsigned int iRef = 0; iRef <
nRefChan; iRef++) {
1215 <<
"-- debug test -- Last Loop apdAmplA:" <<
apdAmplA <<
" apdAmplB:" <<
apdAmplB <<
", event:" <<
event 1232 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
1233 std::vector<double> apdvec =
APDAnal[iCry][iColor]->
getAPD();
1241 for (
unsigned int i = 0;
i < apdvec.size();
i++) {
1242 APD[
i] = apdvec.at(
i);
1273 for (
unsigned int iM = 0; iM <
nMod; iM++) {
1274 unsigned int iMod =
modules[iM] - 1;
1278 for (
unsigned int ch = 0; ch <
nPNPerMod; ch++) {
1285 for (
unsigned int iColor = 0; iColor < nCol; iColor++) {
1286 std::vector<double> pnvec =
PNAnal[iMod][ch][iColor]->
getPN();
1287 std::vector<double> pnopnvec =
PNAnal[iMod][ch][iColor]->
getPNoPN();
1288 std::vector<double> pnopn0vec =
PNAnal[iMod][ch][iColor]->
getPNoPN0();
1289 std::vector<double> pnopn1vec =
PNAnal[iMod][ch][iColor]->
getPNoPN1();
1291 for (
unsigned int i = 0;
i < pnvec.size();
i++) {
1292 PN[
i] = pnvec.at(
i);
1310 std::stringstream del2;
1312 system(del2.str().c_str());
1325 for (
unsigned int i = 0;
i < nCol;
i++) {
1332 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+ .................................................. done +=+";
1333 edm::LogVerbatim(
"EcalLaserAnalyzer") <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+";
1337 int etaG,
int phiG,
int module,
int tower,
int strip,
int xtal,
int apdRefTT,
int channel,
int lmr) {
1349 for (
unsigned int iref = 0; iref <
nRefChan; iref++) {
1370 int etaG,
int phiG,
int iX,
int iY,
int iZ,
int module,
int tower,
int ch,
int apdRefTT,
int channel,
int lmr) {
1382 for (
unsigned int iref = 0; iref <
nRefChan; iref++) {
void addEntry(double val)
Log< level::Info, true > LogVerbatim
static XYCoord localCoord(int icr)
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
TAPD * APDAnal[1700][nColor]
void setAPDCut(double, double)
TPN * PNFirstAnal[22][2][nColor]
const std::string digiProducer_
std::vector< double > getPN()
EcalLaserAnalyzer(const edm::ParameterSet &iConfig)
static int apdRefTower(int ilmr, int ilmmod)
void addEntry(double, double, double)
std::map< int, unsigned int > apdRefMap[2]
const double _ratiomincuthigh
double getDelta(int, int)
std::vector< double > getPNoPN1()
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
~EcalLaserAnalyzer() override
static int side(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
void setPNCut(double, double)
const unsigned int _nsamplesPN
T const * product() const
void addEntry(double, double, double, double, double, double, double)
double getPNCorrectionFactor(double val0, int gain)
std::vector< T >::const_iterator const_iterator
const edm::EDGetTokenT< EcalRawDataCollection > rawDataToken_
const std::string eventHeaderCollection_
ALPAKA_FN_ACC int side(int ieta, int iphi)
void computeShape(std::string namefile, TTree *)
double * getAdcWithoutPedestal()
void putAllVals(int, double *, int, int)
static int lmr(EBGlobalCoord ieta, EBGlobalCoord iphi)
Log< level::Error, false > LogError
TPN * PNAnal[22][2][nColor]
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< double > getAPDoPN0()
void setTimeCut(double, double)
const double _presamplecut
edm::EDGetTokenT< EBDigiCollection > ebDigiToken_
TTree * RefAPDtrees[2][22]
static std::pair< int, int > pn(int ilmmod)
void set2DAPDoAPD1Cut(const std::vector< double > &, const std::vector< double > &)
const unsigned int _nevtmax
const double _ratiomaxcutlow
void setAPDoPN0Cut(double, double)
std::vector< double > getPNoPN0()
std::vector< double > getAPDoPN1()
const unsigned int _niter
const std::string eventHeaderProducer_
int hashedIndex(int ieta, int iphi)
static std::pair< int, int > pn(int dee, int ilmod)
std::vector< double > getAPDoAPD0()
void set2DAPDoAPD0Cut(const std::vector< double > &, const std::vector< double > &)
TAPD * APDFirstAnal[1700][nColor]
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
unsigned int firstChanMod[22]
const unsigned int _timingqualhigh
const std::string digiPNCollection_
const unsigned int _nsamples
unsigned int isFirstChanModFilled[22]
int towerId() const
get the tower id
double * getAdcWithoutPedestal()
static int apdRefTower(int ilmmod)
int channelId() const
so far for EndCap only :
#define DEFINE_FWK_MODULE(type)
const_iterator begin() const
const unsigned int _lastsamplePN
const unsigned int _lastsample
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
std::vector< double > getAPDoAPD1()
virtual void init(int, int, int, int, double, double)
std::vector< double > getAPD()
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > mappingToken_
std::map< unsigned int, unsigned int > channelMapEE
unsigned int iModule[1700]
const_iterator end() const
const std::string resdir_
std::string alphainitfile
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
const unsigned int _timingcutlow
void setGeomEB(int etaG, int phiG, int module, int tower, int strip, int xtal, int apdRefTT, int channel, int lmr)
int stripId() const
get the tower id
const bool _saveallevents
virtual double doFit(double *)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void setGeomEE(int etaG, int phiG, int iX, int iY, int iZ, int module, int tower, int ch, int apdRefTT, int channel, int lmr)
edm::EDGetTokenT< EEDigiCollection > eeDigiToken_
int iPnId() const
get the PnId
int IsThereDataADC[1700][nColor]
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
std::vector< double > getVals(int)
void set_const(int, int, int, int, int, double, double)
int xtalId() const
get the channel id
const unsigned int _timingcuthigh
const unsigned int _presamplePN
std::vector< double > getPNoPN()
const edm::EDGetTokenT< EcalPnDiodeDigiCollection > pnDiodeDigiToken_
const unsigned int _firstsample
const unsigned int _firstsamplePN
const double _qualpercent
static int dee(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
unsigned int nevtAB[1700]
double doFit(int, double *)
std::vector< double > getAPDoPN()
const std::string digiCollection_
int iDCCId() const
get the DCCId
const std::string pncorfile_
const double _ratiomincutlow
const unsigned int _timingquallow
TTree * respntrees[nColor]
std::vector< double > getTime()
static std::vector< int > apdRefChannels(ME::LMMid ilmmod, ME::LMRid ilmr)
static std::vector< ME::LMMid > lmmodFromDcc(ME::DCCid idcc)
static int lmr(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
const std::string _ecalPart
void setAPDoPNCut(double, double)
void setAPDoPN1Cut(double, double)