58 _nsamples( iConfig.getUntrackedParameter< unsigned int >(
"nSamples", 10 ) ),
59 _presample( iConfig.getUntrackedParameter< unsigned int >(
"nPresamples", 3 ) ),
60 _firstsample( iConfig.getUntrackedParameter< unsigned int >(
"firstSample", 1 ) ),
61 _lastsample( iConfig.getUntrackedParameter< unsigned int >(
"lastSample", 2 ) ),
62 _samplemin( iConfig.getUntrackedParameter< unsigned int >(
"sampleMin", 3 ) ),
63 _samplemax( iConfig.getUntrackedParameter< unsigned int >(
"sampleMax", 9 ) ),
64 _nsamplesPN( iConfig.getUntrackedParameter< unsigned int >(
"nSamplesPN", 50 ) ),
65 _presamplePN( iConfig.getUntrackedParameter< unsigned int >(
"nPresamplesPN", 6 ) ),
66 _firstsamplePN( iConfig.getUntrackedParameter< unsigned int >(
"firstSamplePN", 7 ) ),
67 _lastsamplePN( iConfig.getUntrackedParameter< unsigned int >(
"lastSamplePN", 8 ) ),
68 _niter( iConfig.getUntrackedParameter< unsigned int >(
"nIter", 3 ) ),
69 _chi2max( iConfig.getUntrackedParameter< double >(
"chi2Max", 10.0 ) ),
70 _timeofmax( iConfig.getUntrackedParameter< double >(
"timeOfMax", 4.5 ) ),
71 _ecalPart( iConfig.getUntrackedParameter< std::string >(
"ecalPart",
"EB" ) ),
72 _fedid( iConfig.getUntrackedParameter< int >(
"fedID", -999 ) ),
78 towerID(-1), channelID(-1),
runType(-1), runNum(0), fedID(-1), dccID(-1), side(-1), iZ(1),
79 phi(-1),
eta(-1),
event(0), apdAmpl(0),apdTime(0),pnAmpl(0),
80 pnID(-1), moduleID(-1), channelIteratorEE(0)
137 rootfile+=
"/TmpTreeTestPulseAnalyzer.root";
143 std::stringstream
name;
146 trees[
i]=
new TTree(name.str().c_str(),name.str().c_str());
150 trees[
i]->Branch(
"iphi", &
phi,
"phi/I" );
151 trees[
i]->Branch(
"ieta", &
eta,
"eta/I" );
163 trees[
i]->SetBranchAddress(
"ieta", &
eta );
164 trees[
i]->SetBranchAddress(
"iphi", &
phi );
190 for(
unsigned int j=0;
j<
nMod;
j++){
198 namefile <<
resdir_ <<
"/APDPN_TESTPULSE.root";
218 DCCHeader=pDCCHeader.
product();
265 TheMapping = ecalmapping.
product();
267 std::cerr <<
"Error! can't get the product EcalMappingRcd"<< std::endl;
278 int fed = headerItr->fedId();
282 runType=headerItr->getRunType();
283 runNum=headerItr->getRunNumber();
284 event=headerItr->getLV1();
286 dccID=headerItr->getDccInTCCCommand();
287 fedID=headerItr->fedId();
324 std::map <int, std::vector<double> > allPNAmpl;
325 std::map <int, std::vector<int> > allPNGain;
331 bool isMemRelevant=
false;
332 for (
unsigned int imem=0;imem<
dccMEM.size();imem++){
339 if(!isMemRelevant)
continue;
341 for (
int samId=0; samId < (*pnItr).size() ; samId++ ) {
342 pn[samId]=(*pnItr).sample(samId).adc();
343 pnG[samId]=(*pnItr).sample(samId).gainId();
345 if(pnG[samId]!=1)
std::cout <<
"PN gain different from 1 for sample "<<samId<< std::endl;
346 if (samId==0) pngain=pnG[samId];
347 if (samId>0) pngain=
TMath::Max(pnG[samId],pngain);
353 bl=dsum/((double) _presamplePN);
357 ypnrange[
k]=
pn[
k] - bl;
359 if(ypnrange[k] > val_max) {
360 val_max= ypnrange[
k]; samplemax=
k;
364 chi2pn = pnfit -> doFit(samplemax,&ypnrange[0]);
366 if(chi2pn == 101 || chi2pn == 102 || chi2pn == 103)
pnAmpl=0.;
367 else pnAmpl= pnfit -> getAmpl();
370 allPNGain[pnDetId.
iDCCId()].push_back(pngain);
380 pstpfit -> init_errmat(10.);
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();
424 unsigned int MyPn0=pnpair.first;
425 unsigned int MyPn1=pnpair.second;
447 for (
unsigned int i=0;
i< (*digiItr).size() ; ++
i ) {
450 adc[
i]=samp_crystal.adc() ;
451 adcG[
i]=samp_crystal.gainId();
453 if (
i==0) adcgain=adcG[
i];
460 if(k<_presample-1) dsum1+=
adc[
k];
463 bl=dsum/((double)_presample);
466 yrange[
k]=
adc[
k] - bl;
467 if(yrange[k] > val_max) {
468 val_max= yrange[
k]; samplemax=
k;
485 chi2 = pstpfit -> fit_third_degree_polynomial(&yrange[0],
ret_data);
490 if( val_max > 100000. || chi2 < 0. || chi2 == 102 ) {
502 trees[channel]->Fill();
510 EEDetId id_crystal(digiItr->id()) ;
513 phi = id_crystal.ix() ;
514 eta = id_crystal.iy() ;
516 int iX = (
phi-1)/5+1;
517 int iY = (
eta-1)/5+1;
531 if( module>=18 &&
side==1 ) module+=2;
538 unsigned int MyPn0=pnpair.first;
539 unsigned int MyPn1=pnpair.second;
563 assert (channel <
nCrys);
568 for (
unsigned int i=0;
i< (*digiItr).size() ; ++
i ) {
571 adc[
i]=samp_crystal.adc() ;
572 adcG[
i]=samp_crystal.gainId();
574 if (
i==0) adcgain=adcG[
i];
583 if(k<_presample-1) dsum1+=
adc[
k];
586 bl=dsum/((double)_presample);
589 yrange[
k]=
adc[
k] - bl;
590 if(yrange[k] > val_max) {
591 val_max= yrange[
k]; samplemax=
k;
597 if(
side==1) dccMEMIndex+=2;
611 chi2 = pstpfit -> fit_third_degree_polynomial(&yrange[0],
ret_data);
616 if( val_max > 100000. || chi2 < 0. || chi2 == 102 ) {
628 trees[channel]->Fill();
648 std::stringstream del;
650 system(del.str().c_str());
652 std::cout <<
" No TP Events "<< std::endl;
656 std::cout <<
"\n\t+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+" << std::endl;
657 std::cout <<
"\t+=+ Analyzing test pulse data: getting APD, PN +=+" << std::endl;
666 restrees=
new TTree(
"TPAPD",
"TPAPD");
669 restrees->Branch(
"iphi", &
iphi,
"iphi/I" );
670 restrees->Branch(
"ieta", &
ieta,
"ieta/I" );
671 restrees->Branch(
"dccID", &
dccID,
"dccID/I" );
672 restrees->Branch(
"side", &
side,
"side/I" );
673 restrees->Branch(
"towerID", &
towerID,
"towerID/I" );
674 restrees->Branch(
"channelID", &
channelID,
"channelID/I" );
675 restrees->Branch(
"moduleID", &
moduleID,
"moduleID/I" );
676 restrees->Branch(
"flag", &
flag,
"flag/I" );
677 restrees->Branch(
"gain", &
gain,
"gain/I" );
678 restrees->Branch(
"APD", &
APD,
"APD[6]/D" );
685 restrees->SetBranchAddress(
"iphi", &
iphi );
686 restrees->SetBranchAddress(
"ieta", &
ieta );
687 restrees->SetBranchAddress(
"dccID", &
dccID );
688 restrees->SetBranchAddress(
"side", &
side );
689 restrees->SetBranchAddress(
"towerID", &
towerID );
690 restrees->SetBranchAddress(
"channelID", &
channelID );
691 restrees->SetBranchAddress(
"moduleID", &
moduleID );
692 restrees->SetBranchAddress(
"flag", &
flag );
693 restrees->SetBranchAddress(
"gain", &
gain );
694 restrees->SetBranchAddress(
"APD",
APD );
703 TMom *APDAnal[1700][10];
704 TMom *PNAnal[9][2][10];
707 for (
unsigned int iMod=0;iMod<
nMod;iMod++){
708 for (
unsigned int ich=0;ich<2;ich++){
709 for (
unsigned int ig=0;ig<
nGainPN;ig++){
710 PNAnal[iMod][ich][ig]=
new TMom();
715 for (
unsigned int iCry=0;iCry<
nCrys;iCry++){
717 for(
unsigned int iG=0;iG<
nGainAPD;iG++){
718 APDAnal[iCry][iG]=
new TMom();
725 unsigned int iMod=
iModule[iCry]-1;
730 Long64_t nbytes = 0, nb = 0;
731 for (Long64_t jentry=0; jentry<
trees[iCry]->GetEntriesFast();jentry++) {
732 nb =
trees[iCry]->GetEntry(jentry); nbytes += nb;
747 if (
trees[iCry]->GetEntries()<10){
749 for (
int j=0;
j<6;
j++){
762 for (
unsigned int ig=0;ig<
nGainAPD;ig++){
781 for (
unsigned int ig=0;ig<
nGainPN;ig++){
782 for (
unsigned int iMod=0;iMod<
nMod;iMod++){
783 for (
int ch=0;ch<2;ch++){
790 PN[1]= PNAnal[iMod][ch][ig]->
getRMS();
791 PN[2]= PNAnal[iMod][ch][ig]->
getM3();
793 PN[4]= PNAnal[iMod][ch][ig]->
getMin();
794 PN[5]= PNAnal[iMod][ch][ig]->
getMax();
808 std::stringstream del;
810 system(del.str().c_str());
819 std::cout <<
"\t+=+ ...................................... done +=+" << std::endl;
820 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
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
std::vector< int > modules
int stripId() const
get the tower id
#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::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
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)
unsigned int iModule[NCRYSEB]
static int electronic_channel(EBLocalCoord ix, EBLocalCoord iy)
std::string digiPNCollection_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int iDCCId() const
get the DCCId
static int lmmod(EBGlobalCoord ieta, EBGlobalCoord iphi)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const_iterator end() const
static int side(EBGlobalCoord ieta, EBGlobalCoord iphi)
T const * product() const
T const * product() const
const_iterator end() const
std::vector< int > dccMEM
unsigned int isFirstChanModFilled[NMODEB]
unsigned int firstChanMod[NMODEB]
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
static std::vector< ME::LMMid > lmmodFromDcc(ME::DCCid idcc)
tuple size
Write out results.
int channelId() const
so far for EndCap only :
const_iterator begin() const