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 _niter(iConfig.getUntrackedParameter<unsigned
int>(
"nIter", 3)),
62 _chi2max(iConfig.getUntrackedParameter<double>(
"chi2Max", 10.0)),
63 _timeofmax(iConfig.getUntrackedParameter<double>(
"timeOfMax", 4.5)),
64 _ecalPart(iConfig.getUntrackedParameter<
std::
string>(
"ecalPart",
"EB")),
65 _fedid(iConfig.getUntrackedParameter<
int>(
"fedID", -999)),
137 rootfile +=
"/TmpTreeTestPulseAnalyzer.root";
141 for (
unsigned int i = 0;
i <
nCrys;
i++) {
142 std::stringstream
name;
145 trees[
i] =
new TTree(name.str().c_str(), name.str().c_str());
162 trees[
i]->SetBranchAddress(
"ieta", &
eta);
163 trees[
i]->SetBranchAddress(
"iphi", &
phi);
178 for (
unsigned int j = 0;
j <
nCrys;
j++) {
188 for (
unsigned int j = 0;
j <
nMod;
j++) {
195 std::stringstream namefile;
196 namefile <<
resdir_ <<
"/APDPN_TESTPULSE.root";
214 DCCHeader = pDCCHeader.
product();
258 TheMapping = ecalmapping.
product();
260 std::cerr <<
"Error! can't get the product EcalMappingRcd" << std::endl;
269 int fed = headerItr->fedId();
274 runType = headerItr->getRunType();
275 runNum = headerItr->getRunNumber();
276 event = headerItr->getLV1();
278 dccID = headerItr->getDccInTCCCommand();
279 fedID = headerItr->fedId();
317 std::map<int, std::vector<double> > allPNAmpl;
318 std::map<int, std::vector<int> > allPNGain;
325 bool isMemRelevant =
false;
326 for (
unsigned int imem = 0; imem <
dccMEM.size(); imem++) {
328 isMemRelevant =
true;
336 for (
int samId = 0; samId < (*pnItr).size(); samId++) {
337 pn[samId] = (*pnItr).sample(samId).adc();
338 pnG[samId] = (*pnItr).sample(samId).gainId();
341 std::cout <<
"PN gain different from 1 for sample " << samId << std::endl;
351 bl = dsum / ((double)_presamplePN);
354 ypnrange[
k] =
pn[
k] - bl;
356 if (ypnrange[k] > val_max) {
357 val_max = ypnrange[
k];
362 chi2pn = pnfit->
doFit(samplemax, &ypnrange[0]);
364 if (chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
370 allPNGain[pnDetId.
iDCCId()].push_back(pngain);
391 EBDetId id_crystal(digiItr->id());
394 int etaG = id_crystal.ieta();
395 int phiG = id_crystal.iphi();
401 etaL = LocalCoord.first;
402 phiL = LocalCoord.second;
413 int xtal = elecid_crystal.
xtalId();
417 int iMod = module - 1;
423 unsigned int MyPn0 = pnpair.first;
424 unsigned int MyPn1 = pnpair.second;
444 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
446 adc[
i] = samp_crystal.adc();
447 adcG[
i] = samp_crystal.gainId();
456 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
458 if (k < _presample - 1)
462 bl = dsum / ((double)_presample);
464 for (val_max = 0., k = 0; k <
_nsamples; k++) {
465 yrange[
k] =
adc[
k] - bl;
466 if (yrange[k] > val_max) {
496 if (val_max > 100000. || chi2 < 0. || chi2 == 102) {
505 trees[channel]->Fill();
512 EEDetId id_crystal(digiItr->id());
515 phi = id_crystal.ix();
516 eta = id_crystal.iy();
518 int iX = (
phi - 1) / 5 + 1;
519 int iY = (
eta - 1) / 5 + 1;
531 if (module >= 18 &&
side == 1)
533 int iMod = module - 1;
540 unsigned int MyPn0 = pnpair.first;
541 unsigned int MyPn1 = pnpair.second;
565 assert(channel <
nCrys);
570 for (
unsigned int i = 0;
i < (*digiItr).size(); ++
i) {
572 adc[
i] = samp_crystal.adc();
573 adcG[
i] = samp_crystal.gainId();
583 for (dsum = 0., dsum1 = 0., k = 0; k <
_presample; k++) {
585 if (k < _presample - 1)
589 bl = dsum / ((double)_presample);
591 for (val_max = 0., k = 0; k <
_nsamples; k++) {
592 yrange[
k] =
adc[
k] - bl;
593 if (yrange[k] > val_max) {
604 if (allPNAmpl[
dccMEM[dccMEMIndex]].
size() > MyPn0)
608 if (allPNAmpl[
dccMEM[dccMEMIndex + 1]].
size() > MyPn1)
613 if (allPNGain[
dccMEM[dccMEMIndex]].
size() > MyPn0)
626 if (val_max > 100000. || chi2 < 0. || chi2 == 102) {
635 trees[channel]->Fill();
651 std::stringstream del;
653 system(del.str().c_str());
655 std::cout <<
" No TP Events " << std::endl;
659 std::cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
660 std::cout <<
"\t+=+ Analyzing test pulse data: getting APD, PN +=+" << std::endl;
668 restrees =
new TTree(
"TPAPD",
"TPAPD");
671 restrees->Branch(
"iphi", &
iphi,
"iphi/I");
672 restrees->Branch(
"ieta", &
ieta,
"ieta/I");
673 restrees->Branch(
"dccID", &
dccID,
"dccID/I");
674 restrees->Branch(
"side", &
side,
"side/I");
675 restrees->Branch(
"towerID", &
towerID,
"towerID/I");
676 restrees->Branch(
"channelID", &
channelID,
"channelID/I");
677 restrees->Branch(
"moduleID", &
moduleID,
"moduleID/I");
678 restrees->Branch(
"flag", &
flag,
"flag/I");
679 restrees->Branch(
"gain", &
gain,
"gain/I");
680 restrees->Branch(
"APD", &
APD,
"APD[6]/D");
687 restrees->SetBranchAddress(
"iphi", &
iphi);
688 restrees->SetBranchAddress(
"ieta", &
ieta);
689 restrees->SetBranchAddress(
"dccID", &
dccID);
690 restrees->SetBranchAddress(
"side", &
side);
691 restrees->SetBranchAddress(
"towerID", &
towerID);
692 restrees->SetBranchAddress(
"channelID", &
channelID);
693 restrees->SetBranchAddress(
"moduleID", &
moduleID);
694 restrees->SetBranchAddress(
"flag", &
flag);
695 restrees->SetBranchAddress(
"gain", &
gain);
696 restrees->SetBranchAddress(
"APD",
APD);
703 TMom* APDAnal[1700][10];
704 TMom* PNAnal[9][2][10];
706 for (
unsigned int iMod = 0; iMod <
nMod; iMod++) {
707 for (
unsigned int ich = 0; ich < 2; ich++) {
708 for (
unsigned int ig = 0; ig <
nGainPN; ig++) {
709 PNAnal[iMod][ich][ig] =
new TMom();
714 for (
unsigned int iCry = 0; iCry <
nCrys; iCry++) {
716 for (
unsigned int iG = 0; iG <
nGainAPD; iG++) {
717 APDAnal[iCry][iG] =
new TMom();
722 unsigned int iMod =
iModule[iCry] - 1;
728 Long64_t nbytes = 0, nb = 0;
729 for (Long64_t jentry = 0; jentry <
trees[iCry]->GetEntriesFast(); jentry++) {
730 nb =
trees[iCry]->GetEntry(jentry);
745 if (
trees[iCry]->GetEntries() < 10) {
747 for (
int j = 0;
j < 6;
j++) {
760 for (
unsigned int ig = 0; ig <
nGainAPD; ig++) {
763 APD[2] = APDAnal[iCry][ig]->
getM3();
777 for (
unsigned int ig = 0; ig <
nGainPN; ig++) {
778 for (
unsigned int iMod = 0; iMod <
nMod; iMod++) {
779 for (
int ch = 0; ch < 2; ch++) {
786 PN[1] = PNAnal[iMod][ch][ig]->
getRMS();
787 PN[2] = PNAnal[iMod][ch][ig]->
getM3();
789 PN[4] = PNAnal[iMod][ch][ig]->
getMin();
790 PN[5] = PNAnal[iMod][ch][ig]->
getMax();
803 std::stringstream del;
805 system(del.str().c_str());
813 std::cout <<
"\t+=+ ...................................... done +=+" << std::endl;
814 std::cout <<
"\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
std::string eventHeaderProducer_
void addEntry(double val)
static XYCoord localCoord(int icr)
T getParameter(std::string const &) const
std::map< int, int > channelMapEE
T getUntrackedParameter(std::string const &, T const &) const
static int lmmod(SuperCrysCoord iX, SuperCrysCoord iY)
static std::vector< ME::DCCid > memFromDcc(ME::DCCid idcc)
int xtalId() const
get the channel id
unsigned int iModule[1700]
void analyze(const edm::Event &e, const edm::EventSetup &c) override
int stripId() const
get the tower id
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
std::string digiCollection_
static int side(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
std::vector< T >::const_iterator const_iterator
unsigned int _firstsample
int towerId() const
get the tower id
unsigned int _presamplePN
const_iterator begin() const
std::string digiProducer_
std::string eventHeaderCollection_
EcalTestPulseAnalyzer(const edm::ParameterSet &iConfig)
unsigned int _lastsamplePN
double fit_third_degree_polynomial(double *, double *)
unsigned int _firstsamplePN
static std::pair< int, int > pn(int ilmmod)
int hashedIndex(int ieta, int iphi)
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
static std::pair< int, int > pn(int dee, int ilmod)
#define DEFINE_FWK_MODULE(type)
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
std::string digiPNCollection_
int iDCCId() const
get the DCCId
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
unsigned int firstChanMod[9]
const_iterator end() const
~EcalTestPulseAnalyzer() override
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
T const * product() const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const_iterator end() const
std::vector< int > dccMEM
double doFit(int, double *)
EcalLogicID towerID(EcalElectronicsId const &)
void set_params(int, int, int, int, int, double, double, int, int)
unsigned int isFirstChanModFilled[9]
T const * product() const
static std::vector< ME::LMMid > lmmodFromDcc(ME::DCCid idcc)
int channelId() const
so far for EndCap only :
const_iterator begin() const