CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HFLightCal Class Reference

#include <HFLightCal.h>

Inheritance diagram for HFLightCal:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &fEvent, const edm::EventSetup &fSetup)
 
virtual void beginJob ()
 
virtual void endJob (void)
 
 HFLightCal (const edm::ParameterSet &fConfiguration)
 
virtual ~HFLightCal ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

std::string histfile
 
TH2F * hnpemapM
 
TH2F * hnpemapP
 
TH1F * hnpevar
 
TH1F * hped [26][36][2]
 
TH1F * hpedmean
 
TH1F * hpedpin [8][3]
 
TH1F * hpedrms
 
TH2F * hsignalmapM
 
TH2F * hsignalmapP
 
TH1F * hsignalmean
 
TH1F * hsignalrms
 
TH2F * hsignalRMSmapM
 
TH2F * hsignalRMSmapP
 
TH1F * hsp [26][36][2]
 
TH1F * hspe [26][36][2]
 
TH1F * hspepin [8][3]
 
TH1F * hspes
 
TH1F * hsppin [8][3]
 
TH1F * htmax
 
TH1F * htmean
 
TH1F * hts [26][36][2]
 
TH1F * htsm [26][36][2]
 
TH1F * htsmpin [8][3]
 
TH1F * htspin [8][3]
 
TFile * mFile
 
std::string prefile
 
FILE * preFile
 
std::string textfile
 
FILE * tFile
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 11 of file HFLightCal.h.

Constructor & Destructor Documentation

HFLightCal::HFLightCal ( const edm::ParameterSet fConfiguration)

Definition at line 44 of file HFLightCal.cc.

References edm::ParameterSet::getUntrackedParameter().

44  {
45  //std::string histfile = fConfiguration.getUntrackedParameter<string>("rootFile");
46  histfile = fConfiguration.getUntrackedParameter<string>("rootFile");
47  textfile = fConfiguration.getUntrackedParameter<string>("textFile");
48  prefile = fConfiguration.getUntrackedParameter<string>("preFile");
49 }
T getUntrackedParameter(std::string const &, T const &) const
std::string textfile
Definition: HFLightCal.h:27
std::string histfile
Definition: HFLightCal.h:26
std::string prefile
Definition: HFLightCal.h:28
HFLightCal::~HFLightCal ( )
virtual

Definition at line 51 of file HFLightCal.cc.

51  {
52  //delete mFile;
53 }

Member Function Documentation

void HFLightCal::analyze ( const edm::Event fEvent,
const edm::EventSetup fSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 411 of file HFLightCal.cc.

References abs, ecalMGPA::adc(), calib, gather_cfg::cout, HcalDetId::depth(), edm::EventID::event(), eventN, edm::Event::getByType(), HcalForward, HFDataFrame::id(), edm::EventBase::id(), HcalDetId::ieta(), HcalDetId::iphi(), itsmax, edm::EventID::run(), runN, HFDataFrame::size(), and HcalDetId::subdet().

411  {
412 
413  // event ID
414  edm::EventID eventId = fEvent.id();
415  int runNer = eventId.run ();
416  int eventNumber = eventId.event ();
417  if (runN==0) runN=runNer;
418  eventN++;
419  if (verbose) std::cout << "========================================="<<std::endl
420  << "run/event: "<<runNer<<'/'<<eventNumber<<std::endl;
421 
422  Double_t buf[20];
423  Double_t maxADC,signal,ped=0,meant;
424  Int_t maxisample=0,i1=3,i2=6;
425 
426  // HF PIN-diodes
428  fEvent.getByType(calib);
429  if (verbose) std::cout<<"Analysis-> total CAL digis= "<<calib->size()<<std::endl;
430 
431  /* COMMENTED OUT by J. Mans (7-28-2008) as major changes needed with new Calib DetId
432  re-commented out by R.Ofierzynski (11.Nov.2008) - to be able to provide a consistent code for CMSSW_3_0_0_pre3:
433  major changes are needed for the new Calib DetId which does not have the old methods any more
434 
435  for (unsigned j = 0; j < calib->size (); ++j) {
436  const HcalCalibDataFrame digi = (*calib)[j];
437  HcalElectronicsId elecId = digi.elecId();
438  HcalCalibDetId calibId = digi.id();
439  if (verbose) std::cout<<calibId.sectorString().c_str()<<" "<<calibId.rbx()<<" "<<elecId.fiberChanId()<<std::endl;
440  int isector = calibId.rbx()-1;
441  int ipin = elecId.fiberChanId();
442  int iside = -1;
443  if (calibId.sectorString() == "HFP") iside = 0;
444  else if (calibId.sectorString() == "HFM") iside = 4;
445  maxisample = itspinmax[isector+iside][ipin]-1;
446 
447  if (iside != -1) {
448  for (int isample = 0; isample < digi.size(); ++isample) {
449  int adc = digi[isample].adc();
450  int capid = digi[isample].capid ();
451  double linear_ADC = digi[isample].nominal_fC();
452  if (verbose) std::cout<<"PIN linear_ADC = "<<linear_ADC<<" atMAXTS="<<maxisample<<std::endl;
453  htspin[isector+iside][ipin]->Fill(isample,linear_ADC);
454  buf[isample]=linear_ADC;
455  }
456  i1=maxisample-1;
457  i2=maxisample+2;
458  if (i1<0) {i1=0;i2=3;}
459  else if (i2>9) {i1=6;i2=9;}
460  if (i1==0) ped=buf[8]+buf[9]+buf[6]+buf[7];
461  else if (i1==1) ped=buf[8]+buf[9]+buf[6]+buf[7];
462  else if (i1==2) ped=buf[0]+buf[1]+buf[6]+buf[7];
463  else if (i1==3) ped=buf[0]+buf[1]+buf[2]+buf[7];
464  else if (i1>=4) ped=buf[0]+buf[1]+buf[2]+buf[3];
465  signal=0;
466  for (ii=0;ii<4;ii++) signal+=TMath::Max(buf[ii+i1],ped/4.0);
467  hsppin[isector+iside][ipin]->Fill(signal);
468  hspepin[isector+iside][ipin]->Fill(signal);
469  hpedpin[isector+iside][ipin]->Fill(ped);
470 
471  // Mean signal time estimation
472  ped=ped/4;
473  meant=0;
474  for (ii=0;ii<4;ii++) meant+=(TMath::Max(buf[ii+i1],ped)-ped)*(ii+i1);
475  if (signal-ped*4>0) meant/=(signal-ped*4);
476  else meant=i1+1;
477  htsmpin[isector+iside][ipin]->Fill(meant);
478  }
479  }
480  */
481 
482  // HF
484  fEvent.getByType(hf_digi);
485  if (verbose) std::cout<<"Analysis-> total HF digis= "<<hf_digi->size()<<std::endl;
486 
487  for (unsigned ihit = 0; ihit < hf_digi->size (); ++ihit) {
488  const HFDataFrame& frame = (*hf_digi)[ihit];
489  HcalDetId detId = frame.id();
490  int ieta = detId.ieta();
491  int iphi = detId.iphi();
492  int depth = detId.depth();
493  if (verbose) std::cout <<"HF digi # " <<ihit<<": eta/phi/depth: "
494  <<ieta<<'/'<<iphi<<'/'<< depth << std::endl;
495 
496  if (ieta>0) ieta = ieta-29;
497  else ieta = 13-ieta-29;
498 
499  maxADC=-99;
500  for (int isample = 0; isample < frame.size(); ++isample) {
501  int adc = frame[isample].adc();
502  int capid = frame[isample].capid ();
503  double linear_ADC = frame[isample].nominal_fC();
504  double nominal_fC = detId.subdet () == HcalForward ? 2.6 * linear_ADC : linear_ADC;
505 
506  if (verbose) std::cout << "Analysis-> HF sample # " << isample
507  << ", capid=" << capid
508  << ": ADC=" << adc
509  << ", linearized ADC=" << linear_ADC
510  << ", nominal fC=" << nominal_fC <<std::endl;
511 
512  hts[ieta][(iphi-1)/2][depth-1]->Fill(isample,linear_ADC);
513  buf[isample]=linear_ADC;
514  /*
515  if (maxADC<linear_ADC) {
516  maxADC=linear_ADC;
517  maxisample=isample;
518  }
519  */
520  }
521 
522  maxADC=-99;
523  for (int ii=0; ii<10; ii++) {
524  signal=buf[ii];
525  if (ii<2) signal -= (buf[ii+4]+buf[ii+8])/2.0;
526  else if (ii<4) signal -= buf[ii+4];
527  else if (ii<6) signal -= (buf[ii+4]+buf[ii-4])/2.0;
528  else if (ii<8) signal -= buf[ii-4];
529  else signal -= (buf[ii-4]+buf[ii-8])/2.0;
530  if (signal>maxADC) {
531  maxADC=signal;
532  maxisample=ii;
533  }
534  }
535  //maxisample=itsmax[ieta][(iphi-1)/2][depth-1]-1;
536  if (abs(maxisample-itsmax[ieta][(iphi-1)/2][depth-1]+1)>1) maxisample=itsmax[ieta][(iphi-1)/2][depth-1]-1;
537  if (verbose) std::cout<<eventNumber<<"/"<<ihit<<": maxTS="<<maxisample<<endl;
538 
539  // Signal = four capIDs found by PreAnal, Pedestal = four capIDs off the signal
540  htmax->Fill(maxisample);
541  i1=maxisample-1;
542  i2=maxisample+2;
543  if (i1<0) {i1=0;i2=3;}
544  else if (i2>9) {i1=6;i2=9;}
545  else if (i2<9 && maxisample<=itsmax[ieta][(iphi-1)/2][depth-1]-1) {
546  if (buf[i1]<buf[i2+1]) {i1=i1+1;i2=i2+1;}
547  }
548  signal=buf[i1]+buf[i1+1]+buf[i1+2]+buf[i1+3];
549  hsp[ieta][(iphi-1)/2][depth-1]->Fill(signal);
550  hspe[ieta][(iphi-1)/2][depth-1]->Fill(signal);
551  /*
552  if (i1==0) ped=(buf[4]+buf[8])/2.0+(buf[5]+buf[9])/2.0+buf[6]+buf[7];
553  else if (i1==1) ped=(buf[0]+buf[8])/2.0+(buf[5]+buf[9])/2.0+buf[6]+buf[7];
554  else if (i1==2) ped=(buf[0]+buf[8])/2.0+(buf[1]+buf[9])/2.0+buf[6]+buf[7];
555  else if (i1==3) ped=(buf[0]+buf[8])/2.0+(buf[1]+buf[9])/2.0+buf[2]+buf[7];
556  else if (i1==4) ped=(buf[0]+buf[8])/2.0+(buf[1]+buf[9])/2.0+buf[2]+buf[3];
557  else if (i1==5) ped=(buf[0]+buf[4])/2.0+(buf[1]+buf[9])/2.0+buf[2]+buf[3];
558  else if (i1==6) ped=(buf[0]+buf[4])/2.0+(buf[1]+buf[5])/2.0+buf[2]+buf[3];
559  */
560 
561  if (i1<2) ped=buf[8]+buf[9]+buf[6]+buf[7];
562  else if (i1==2) ped=buf[6]+buf[9]+buf[7]+buf[0];
563  else if (i1==3) ped=buf[0]+buf[1]+buf[2]+buf[7];
564  else if (i1>=4) ped=buf[0]+buf[1]+buf[2]+buf[3];
565 
566  hped[ieta][(iphi-1)/2][depth-1]->Fill(ped);
567 
568  // Mean signal time estimation
569  ped=ped/4;
570  meant=(buf[i1]-ped)*i1+(buf[i1+1]-ped)*(i1+1)+(buf[i1+2]-ped)*(i1+2)+(buf[i1+3]-ped)*(i1+3);
571  meant /= (buf[i1]-ped)+(buf[i1+1]-ped)+(buf[i1+2]-ped)+(buf[i1+3]-ped);
572  htmean->Fill(meant);
573  htsm[ieta][(iphi-1)/2][depth-1]->Fill(meant);
574  }
575 }
int adc(sample_type sample)
get the ADC sample (12 bits)
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
Int_t runN
Definition: HFLightCal.cc:35
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
#define abs(x)
Definition: mlp_lapack.h:159
TH1F * htsm[26][36][2]
Definition: HFLightCal.h:33
bool getByType(Handle< PROD > &result) const
Definition: Event.h:403
TH1F * hped[26][36][2]
Definition: HFLightCal.h:36
TH1F * htmean
Definition: HFLightCal.h:38
int depth() const
get the tower depth
Definition: HcalDetId.h:42
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
TH1F * hspe[26][36][2]
Definition: HFLightCal.h:35
TH1F * hts[26][36][2]
Definition: HFLightCal.h:32
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
TH1F * hsp[26][36][2]
Definition: HFLightCal.h:34
Int_t itsmax[26][36][2]
Definition: HFLightCal.cc:36
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
TH1F * htmax
Definition: HFLightCal.h:38
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:41
const HcalDetId & id() const
Definition: HFDataFrame.h:22
Int_t eventN
Definition: HFLightCal.cc:35
void HFLightCal::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 55 of file HFLightCal.cc.

References gather_cfg::cout, cmsRelvalreport::exit, i, itsmax, itspinmax, j, gen::k, and NULL.

55  {
56 
57  char htit[64];
58  Int_t neta,nphi,ndepth,nmax,nquad,npin;
59 
60  std::cout<<std::endl<<"HFLightCal beginJob: --> "<<std::endl;
61 
62  // Read info about signal timing in TS from PreAnalysis
63  mFile = new TFile (histfile.c_str(),"RECREATE");
64  if ((tFile = fopen(textfile.c_str(),"w"))==NULL) {
65  printf("\nNo output textfile open\n\n");
66  std::cout<<"Problem with output textFILE => exit"<<std::endl;
67  exit(1);
68  }
69  //if ((preFile = fopen("hf_preanal.txt","r"))==NULL){
70  if ((preFile = fopen(prefile.c_str(),"r"))==NULL){
71  printf("\nNo input pre-file open\n\n");
72  std::cout<<"Problem with input textFILE => exit"<<std::endl;
73  exit(1);
74  }
75  rewind(preFile);
76  for (int i=0; i<1728; i++) {
77  fscanf(preFile,"%d%d%d%d\r",&neta,&nphi,&ndepth,&nmax);
78  //std::cout<<neta<<" "<<nphi<<" "<<ndepth<<" "<<nmax<<std::endl;
79  if (neta>=29 && neta<=41 && nphi<72 && nphi>0 && ndepth>0 && ndepth<=2)
80  itsmax[neta-29][(nphi-1)/2][ndepth-1] = nmax;
81  else if (neta<=-29 && neta>=-41 && nphi<72 && nphi>0 && ndepth>0 && ndepth<=2)
82  itsmax[13-neta-29][(nphi-1)/2][ndepth-1] = nmax;
83  else {
84  std::cout<<"Input pre-file: wrong channel record:"<<std::endl;
85  std::cout<<"eta="<<neta<<" phi="<<nphi<<" depth="<<ndepth<<" max="<<nmax<<std::endl;
86  }
87  }
88  for (int i=0; i<24; i++) {
89  fscanf(preFile,"%d%d%d\r",&nquad,&npin,&nmax);
90  //std::cout<<nquad<<" "<<npin<<" "<<nmax<<std::endl;
91  if (nquad>0 && nquad<=4 && npin<=3 && npin>0)
92  itspinmax[nquad-1][npin-1] = nmax;
93  else if (nquad<0 && nquad>=-4 && npin<=3 && npin>0)
94  itspinmax[4-nquad-1][npin-1] = nmax;
95  else {
96  std::cout<<"Input pre-file: wrong PIN record:"<<std::endl;
97  std::cout<<"quad="<<nquad<<" pin="<<npin<<" max="<<nmax<<std::endl;
98  }
99  }
100 
101  // General Histos
102  htmax = new TH1F("htmax","Max TS",10,-0.5,9.5);
103  htmean = new TH1F("htmean","Mean signal TS",100,0,10);
104  hsignalmean = new TH1F("hsignalmean","Mean ADC 4maxTS",1201,-25,30000);
105  hsignalrms = new TH1F("hsignalrms","RMS ADC 4maxTS",500,0,500);
106  hpedmean = new TH1F("hpedmean","Mean ADC 4lowTS",200,-10,90);
107  hpedrms = new TH1F("hpedrms","RMS ADC 4lowTS",200,0,100);
108  hspes = new TH1F("hspes","SPE if measured",200,0,40);
109  hnpevar = new TH1F("hnpevar","~N PE input",500,0,500);
110  hsignalmapP = new TH2F("hsignalmapP","Mean(Response) - Mean(Pedestal) HFP;#eta;#phi",26,28.5,41.5,36,0,72);
111  hsignalRMSmapP = new TH2F("hsignalRMSmapP","RMS Response HFP;#eta;#phi",26,28.5,41.5,36,0,72);
112  hnpemapP = new TH2F("hnpemapP","~N PE input HFP;#eta;#phi",26,28.5,41.5,36,0,72);
113  hnpemapP->SetOption("COLZ");hsignalmapP->SetOption("COLZ");hsignalRMSmapP->SetOption("COLZ");
114  hsignalmapM = new TH2F("hsignalmapM","Mean(Response) - Mean(Pedestal) HFM;#eta;#phi",26,-41.5,-28.5,36,0,72);
115  hsignalRMSmapM = new TH2F("hsignalRMSmapM","RMS Response HFM;#eta;#phi",26,-41.5,-28.5,36,0,72);
116  hnpemapM = new TH2F("hnpemapM","~N PE input HFM;#eta;#phi",26,-41.5,-28.5,36,0,72);
117  hnpemapM->SetOption("COLZ");hsignalmapM->SetOption("COLZ");hsignalRMSmapM->SetOption("COLZ");
118  // Channel-by-channel histos
119  for (int i=0;i<13;i++) for (int j=0;j<36;j++) for (int k=0;k<2;k++) {
120  if (i>10 && j%2==0) continue;
121  sprintf(htit,"ts_+%d_%d_%d",i+29,j*2+1,k+1);
122  hts[i][j][k] = new TH1F(htit,htit,10,-0.5,9.5); // TimeSlices (pulse shape)
123  sprintf(htit,"tsmean_+%d_%d_%d",i+29,j*2+1,k+1);
124  htsm[i][j][k] = new TH1F(htit,htit,100,0,10); // Mean signal time estimated from TS
125  sprintf(htit,"sp_+%d_%d_%d",i+29,j*2+1,k+1);
126  hsp[i][j][k] = new TH1F(htit,htit,1201,-25,30000); // Big-scale spectrum (linear ADC)
127  sprintf(htit,"spe_+%d_%d_%d",i+29,j*2+1,k+1);
128  hspe[i][j][k] = new TH1F(htit,htit,200,-9.5,190.5); // Small-scale spectrum (linear ADC)
129  sprintf(htit,"ped_+%d_%d_%d",i+29,j*2+1,k+1);
130  hped[i][j][k] = new TH1F(htit,htit,200,-9.5,190.5); // Pedestal spectrum
131  sprintf(htit,"ts_-%d_%d_%d",i+29,j*2+1,k+1);
132  hts[i+13][j][k] = new TH1F(htit,htit,10,-0.5,9.5);
133  sprintf(htit,"tsmean_-%d_%d_%d",i+29,j*2+1,k+1);
134  htsm[i+13][j][k] = new TH1F(htit,htit,100,0,10);
135  sprintf(htit,"sp_-%d_%d_%d",i+29,j*2+1,k+1);
136  hsp[i+13][j][k] = new TH1F(htit,htit,1201,-25,30000);
137  sprintf(htit,"spe_-%d_%d_%d",i+29,j*2+1,k+1);
138  hspe[i+13][j][k] = new TH1F(htit,htit,200,-9.5,190.5);
139  sprintf(htit,"ped_-%d_%d_%d",i+29,j*2+1,k+1);
140  hped[i+13][j][k] = new TH1F(htit,htit,200,-9.5,190.5);
141  }
142  // PIN-diodes histos
143  for (int i=0;i<4;i++) for (int j=0;j<3;j++) {
144  sprintf(htit,"ts_PIN%d_+Q%d",j+1,i+1);
145  htspin[i][j] = new TH1F(htit,htit,10,-0.5,9.5);
146  sprintf(htit,"sp_PIN%d_+Q%d",j+1,i+1);
147  hsppin[i][j] = new TH1F(htit,htit,1601,-25,40000);
148  sprintf(htit,"spe_PIN%d_+Q%d",j+1,i+1);
149  hspepin[i][j] = new TH1F(htit,htit,200,-9.5,190.5);
150  sprintf(htit,"ped_PIN%d_+Q%d",j+1,i+1);
151  hpedpin[i][j] = new TH1F(htit,htit,200,-9.5,190.5);
152  sprintf(htit,"tsmean_PIN%d_+Q%d",j+1,i+1);
153  htsmpin[i][j] = new TH1F(htit,htit,100,0,10);
154  sprintf(htit,"ts_PIN%d_-Q%d",j+1,i+1);
155  htspin[i+4][j] = new TH1F(htit,htit,10,-0.5,9.5);
156  sprintf(htit,"sp_PIN%d_-Q%d",j+1,i+1);
157  hsppin[i+4][j] = new TH1F(htit,htit,1601,-25,40000);
158  sprintf(htit,"spe_PIN%d_-Q%d",j+1,i+1);
159  hspepin[i+4][j] = new TH1F(htit,htit,200,-9.5,190.5);
160  sprintf(htit,"ped_PIN%d_-Q%d",j+1,i+1);
161  hpedpin[i+4][j] = new TH1F(htit,htit,200,-9.5,190.5);
162  sprintf(htit,"tsmean_PIN%d_-Q%d",j+1,i+1);
163  htsmpin[i+4][j] = new TH1F(htit,htit,100,0,10);
164  }
165  std::cout<<std::endl<<"histfile="<<histfile.c_str()<<" textfile="<<textfile.c_str()<<std::endl;
166  return;
167 }
TH1F * hpedrms
Definition: HFLightCal.h:38
TH1F * hsignalrms
Definition: HFLightCal.h:38
int i
Definition: DBlmapReader.cc:9
TH2F * hsignalRMSmapM
Definition: HFLightCal.h:37
TH1F * hsppin[8][3]
Definition: HFLightCal.h:40
TH1F * htsm[26][36][2]
Definition: HFLightCal.h:33
#define NULL
Definition: scimark2.h:8
TH1F * hped[26][36][2]
Definition: HFLightCal.h:36
FILE * preFile
Definition: HFLightCal.h:31
TH1F * hpedpin[8][3]
Definition: HFLightCal.h:42
TH1F * htmean
Definition: HFLightCal.h:38
std::string textfile
Definition: HFLightCal.h:27
TH2F * hnpemapM
Definition: HFLightCal.h:37
TH1F * hspe[26][36][2]
Definition: HFLightCal.h:35
TH1F * hts[26][36][2]
Definition: HFLightCal.h:32
TH1F * htspin[8][3]
Definition: HFLightCal.h:39
FILE * tFile
Definition: HFLightCal.h:30
int j
Definition: DBlmapReader.cc:9
TH2F * hsignalRMSmapP
Definition: HFLightCal.h:37
TFile * mFile
Definition: HFLightCal.h:29
TH1F * hsp[26][36][2]
Definition: HFLightCal.h:34
Int_t itsmax[26][36][2]
Definition: HFLightCal.cc:36
TH1F * hnpevar
Definition: HFLightCal.h:38
std::string histfile
Definition: HFLightCal.h:26
int k[5][pyjets_maxn]
TH1F * hspes
Definition: HFLightCal.h:38
TH2F * hsignalmapP
Definition: HFLightCal.h:37
TH1F * htsmpin[8][3]
Definition: HFLightCal.h:43
TH2F * hsignalmapM
Definition: HFLightCal.h:37
TH1F * hsignalmean
Definition: HFLightCal.h:38
TH1F * htmax
Definition: HFLightCal.h:38
TH2F * hnpemapP
Definition: HFLightCal.h:37
TH1F * hpedmean
Definition: HFLightCal.h:38
Int_t itspinmax[8][3]
Definition: HFLightCal.cc:37
tuple cout
Definition: gather_cfg.py:41
std::string prefile
Definition: HFLightCal.h:28
TH1F * hspepin[8][3]
Definition: HFLightCal.h:41
void HFLightCal::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 234 of file HFLightCal.cc.

References gather_cfg::cout, ExpressReco_HICollisions_FallBack::e, eventN, FitFun(), HistSpecs(), i, j, gen::k, plotscripts::mean(), Nev, Gflash::par, plotscripts::rms(), and runN.

235 {
236  Double_t mean,rms,meanped,rmsped,npevar;
237  Double_t par[5],dspe=0,dnpe;
238  Int_t tsmax,intspe;
239  std::cout<<std::endl<<"HFLightCal endJob --> ";
240  fprintf(tFile,"#RunN %d Events processed %d",runN,eventN);
241 
242  for (int i=0;i<26;i++) for (int j=0;j<36;j++) for (int k=0;k<2;k++) {
243  if (i>10 && i<13 && j%2==0) continue;
244  if (i>23 && j%2==0) continue;
245  meanped=rmsped=mean=rms=0;
246  if (hsp[i][j][k]->Integral()>0) {
247  HistSpecs(hped[i][j][k],meanped,rmsped);
248  HistSpecs(hsp[i][j][k],mean,rms);
249  if (hspe[i][j][k]->Integral()>hsp[i][j][k]->Integral()*0.9 || mean<100) {
250  HistSpecs(hspe[i][j][k],mean,rms);
251  }
252  hsignalmean->Fill(mean);
253  hsignalrms->Fill(rms);
254  hpedmean->Fill(meanped);
255  hpedrms->Fill(rmsped);
256  }
257  }
258 
259  meanped=hpedmean->GetMean();
260  rmsped=hpedrms->GetMean();
261  mean=hsignalmean->GetMean();
262  rms=hsignalrms->GetMean();
263  fprintf(tFile," MeanInput=<%.2f> [linADCcount] RMS=<%.2f>\n",mean,rms);
264  fprintf(tFile,"#eta/phi/depth sum4maxTS RMS ~N_PE sum4lowTS RMS maxTS SPE +/- Err Comment\n");
265  TF1* fPed = new TF1("fPed","gaus",0,120);
266  fPed->SetNpx(200);
267  TF1 *fTot = new TF1("fTot",FitFun ,0,200,5);
268  fTot->SetNpx(800);
269  for (int i=0;i<26;i++) for (int j=0;j<36;j++) for (int k=0;k<2;k++) {
270  if (i>10 && i<13 && j%2==0) continue;
271  if (i>23 && j%2==0) continue;
272  HistSpecs(hped[i][j][k],meanped,rmsped);
273  HistSpecs(hsp[i][j][k],mean,rms);
274  par[3]=0;
275  if (hspe[i][j][k]->Integral()>hsp[i][j][k]->Integral()*0.9 || mean<100) {
276  HistSpecs(hspe[i][j][k],mean,rms);
277  if (hspe[i][j][k]->Integral(1,(int) (meanped+3*rmsped+12))/Nev>0.1) {
278  //if (hspe[i][j][k]->Integral()>100 && mean-meanped<100) {
279  if (mean+rms*3-meanped-rmsped*3>2 && rmsped>0) { // SPE fit if low intensity>0
280  par[1] = meanped;
281  par[2] = rmsped;
282  par[0] = hped[i][j][k]->GetMaximum();
283  fPed->SetParameters(par);
284  hped[i][j][k]->Fit(fPed,"BQ0");
285  fPed->GetParameters(&par[0]);
286  hped[i][j][k]->Fit(fPed,"B0Q","",par[1]-par[2]*3,par[1]+par[2]*3);
287  fPed->GetParameters(par);
288  hped[i][j][k]->Fit(fPed,"BLIQ","",par[1]-par[2]*3,par[1]+par[2]*3);
289  fPed->GetParameters(&par[0]);
290  Nev = (int) hspe[i][j][k]->Integral();
291  par[0]=0.1;
292  par[3]=10;
293  par[4]=6;
294  fTot->SetParameters(par);
295  fTot->SetParLimits(0,0,2);
296  //fTot->FixParameter(1,par[1]);
297  fTot->SetParLimits(1,par[1]-1,par[1]+1);
298  fTot->FixParameter(2,par[2]);
299  fTot->SetParLimits(3,1.2,100);
300  //fTot->SetParLimits(4,-1.64,1.64);
301  //fTot->SetParLimits(5,0.5,3);
302  hspe[i][j][k]->Fit(fTot,"BLEQ","");
303  fTot->GetParameters(par);
304  hspe[i][j][k]->Fit(fTot,"BLEQ","",-10,par[1]+par[3]*5);
305  fTot->GetParameters(par);
306  dspe=fTot->GetParError(3);
307  dnpe=fTot->GetParError(0);
308  if (par[3]<1.21 || dnpe>par[0]) par[3]=-1;
309  else if (par[0]>1.96 || par[3]>49) par[3]=0;
310  else {
311  hspes->Fill(par[3]);
312  }
313  }
314  }
315  }
316 
317  // NPE
318  npevar=0;
319  if (par[3]>0) npevar=par[0]; // NPE from SPE fit
320  else { // NPE from high intensity signal
321  if (hspe[i][j][k]->Integral()>hsp[i][j][k]->Integral()*0.98) {
322  HistSpecs(hspe[i][j][k],mean,rms,3);
323  }
324  else {
325  HistSpecs(hsp[i][j][k],mean,rms,3);
326  }
327  if (rmsped>0) {
328  if (rms*rms-rmsped*rmsped>1 && mean>meanped) {
329  npevar=(mean-meanped)*(mean-meanped)/(rms*rms-rmsped*rmsped);
330  }
331  else if (mean<100) {
332  intspe=int(hspe[i][j][k]->Integral());
333  hspe[i][j][k]->SetAxisRange(meanped+rmsped*4,300);
334  npevar=hspe[i][j][k]->Integral()/intspe;
335  if (npevar>0.01) npevar=-1;
336  else npevar=0;
337  hspe[i][j][k]->SetAxisRange(-20,300);
338  }
339  }
340  }
341  if (npevar>5.0e-5) hnpevar->Fill(npevar);
342 
343  if (i<13) {
344  hsignalmapP->Fill(i+28.6+k/2.0,j*2+1,mean-meanped);
345  hsignalRMSmapP->Fill(i+28.6+k/2.0,j*2+1,rms);
346  if (npevar>0) hnpemapP->Fill(i+28.6+k/2.0,j*2+1,npevar);
347  fprintf(tFile,"%3d%4d%5d %11.2f%8.2f",i+29,j*2+1,k+1,mean,rms);
348  }
349  else {
350  fprintf(tFile,"%3d%4d%5d %11.2f%8.2f",13-i-29,j*2+1,k+1,mean,rms);
351  hsignalmapM->Fill(13-i-28.6-k/2.0,j*2+1,mean-meanped);
352  hsignalRMSmapM->Fill(13-i-28.6-k/2.0,j*2+1,rms);
353  if (npevar>0) hnpemapM->Fill(13-i-28.6-k/2.0,j*2+1,npevar);
354  }
355  if (npevar>0) fprintf(tFile," %9.4f",npevar);
356  else fprintf(tFile," 0 ");
357  fprintf(tFile," %8.2f%8.2f",meanped,rmsped);
358  tsmax=hts[i][j][k]->GetMaximumBin()-1;
359  fprintf(tFile," %4d",tsmax);
360  if (par[3]>0 && par[3]<99) fprintf(tFile,"%8.2f%7.2f",par[3],dspe);
361  else if (npevar>0) fprintf(tFile,"%8.2f 0 ",(mean-meanped)/npevar);
362  else fprintf(tFile," 0 0 ");
363 
364  // Diagnostics
365  fprintf(tFile," ");
366  if (hsp[i][j][k]->GetEntries()<=0) fprintf(tFile,"NoSignal\n");
367  else if (hsp[i][j][k]->GetEntries()<=10) fprintf(tFile,"Nev<10\n");
368  else {
369  if (hsp[i][j][k]->Integral()<=10 || mean>12000) fprintf(tFile,"SignalOffRange\n");
370  else {
371  if (hsp[i][j][k]->Integral()<100) fprintf(tFile,"Nev<100/");
372  if (npevar>0 && par[3]>0 && (npevar*Nev<10 || npevar<0.001))
373  fprintf(tFile,"LowSignal/");
374  else if (npevar==0 && fabs(mean-meanped)<3) fprintf(tFile,"LowSignal/");
375  if (par[3]<0) fprintf(tFile,"BadFit/");
376  else if (par[3]==0) fprintf(tFile,"NoSPEFit/");
377  else if (par[3]>0 && npevar>1) fprintf(tFile,"NPE>1/");
378  if (npevar<0) fprintf(tFile,"Problem/");
379  if (mean<2) fprintf(tFile,"LowMean/");
380  if (rms<0.5) fprintf(tFile,"LowRMS/");
381  if (meanped<-1) fprintf(tFile,"LowPed/");
382  else if (meanped>25) fprintf(tFile,"HighPed/");
383  if (rmsped<0.5 && rmsped>0) fprintf(tFile,"NarrowPed/");
384  else if (rmsped>10) fprintf(tFile,"WidePed/");
385  if (hped[i][j][k]->GetBinContent(201)>10) fprintf(tFile,"PedOffRange");
386  fprintf(tFile,"-\n");
387  }
388  }
389  }
390 
391  for (int i=0;i<8;i++) for (int j=0;j<3;j++) {
392  HistSpecs(hpedpin[i][j],meanped,rmsped);
393  HistSpecs(hsppin[i][j],mean,rms);
394  if (hspepin[i][j]->Integral()>hsppin[i][j]->Integral()*0.9 || mean<100) {
395  HistSpecs(hspepin[i][j],mean,rms);
396  }
397  if (i<4) fprintf(tFile," PIN%d +Q%d %12.2f %6.2f",j+1,i+1,mean,rms);
398  else fprintf(tFile," PIN%d -Q%d %12.2f %6.2f",j+1,i-3,mean,rms);
399  fprintf(tFile," %15.2f %6.2f",meanped,rmsped);
400  tsmax=htspin[i][j]->GetMaximumBin()-1;
401  fprintf(tFile," %4d\n",tsmax);
402  }
403 
404  mFile->Write();
405  mFile->Close();
406  fclose(tFile);
407  std::cout<<std::endl<<" --endJob-- done"<<std::endl;
408  return;
409 }
TH1F * hpedrms
Definition: HFLightCal.h:38
TH1F * hsignalrms
Definition: HFLightCal.h:38
int i
Definition: DBlmapReader.cc:9
Int_t runN
Definition: HFLightCal.cc:35
TH2F * hsignalRMSmapM
Definition: HFLightCal.h:37
TH1F * hsppin[8][3]
Definition: HFLightCal.h:40
TH1F * hped[26][36][2]
Definition: HFLightCal.h:36
TH1F * hpedpin[8][3]
Definition: HFLightCal.h:42
TH2F * hnpemapM
Definition: HFLightCal.h:37
TH1F * hspe[26][36][2]
Definition: HFLightCal.h:35
TH1F * hts[26][36][2]
Definition: HFLightCal.h:32
TH1F * htspin[8][3]
Definition: HFLightCal.h:39
FILE * tFile
Definition: HFLightCal.h:30
int j
Definition: DBlmapReader.cc:9
TH2F * hsignalRMSmapP
Definition: HFLightCal.h:37
TFile * mFile
Definition: HFLightCal.h:29
TH1F * hsp[26][36][2]
Definition: HFLightCal.h:34
TH1F * hnpevar
Definition: HFLightCal.h:38
int k[5][pyjets_maxn]
TH1F * hspes
Definition: HFLightCal.h:38
void HistSpecs(TH1F *hist, Double_t &mean, Double_t &rms, Double_t range=4)
Definition: HFLightCal.cc:169
TH2F * hsignalmapP
Definition: HFLightCal.h:37
TH2F * hsignalmapM
Definition: HFLightCal.h:37
TH1F * hsignalmean
Definition: HFLightCal.h:38
TH2F * hnpemapP
Definition: HFLightCal.h:37
TH1F * hpedmean
Definition: HFLightCal.h:38
Int_t Nev
Definition: HFLightCal.cc:35
tuple cout
Definition: gather_cfg.py:41
Double_t FitFun(Double_t *x, Double_t *par)
Definition: HFLightCal.cc:185
Int_t eventN
Definition: HFLightCal.cc:35
const double par[8 *NPar][4]
TH1F * hspepin[8][3]
Definition: HFLightCal.h:41

Member Data Documentation

std::string HFLightCal::histfile
private

Definition at line 26 of file HFLightCal.h.

TH2F * HFLightCal::hnpemapM
private

Definition at line 37 of file HFLightCal.h.

TH2F* HFLightCal::hnpemapP
private

Definition at line 37 of file HFLightCal.h.

TH1F * HFLightCal::hnpevar
private

Definition at line 38 of file HFLightCal.h.

TH1F* HFLightCal::hped[26][36][2]
private

Definition at line 36 of file HFLightCal.h.

TH1F * HFLightCal::hpedmean
private

Definition at line 38 of file HFLightCal.h.

TH1F* HFLightCal::hpedpin[8][3]
private

Definition at line 42 of file HFLightCal.h.

TH1F * HFLightCal::hpedrms
private

Definition at line 38 of file HFLightCal.h.

TH2F * HFLightCal::hsignalmapM
private

Definition at line 37 of file HFLightCal.h.

TH2F * HFLightCal::hsignalmapP
private

Definition at line 37 of file HFLightCal.h.

TH1F* HFLightCal::hsignalmean
private

Definition at line 38 of file HFLightCal.h.

TH1F * HFLightCal::hsignalrms
private

Definition at line 38 of file HFLightCal.h.

TH2F * HFLightCal::hsignalRMSmapM
private

Definition at line 37 of file HFLightCal.h.

TH2F * HFLightCal::hsignalRMSmapP
private

Definition at line 37 of file HFLightCal.h.

TH1F* HFLightCal::hsp[26][36][2]
private

Definition at line 34 of file HFLightCal.h.

TH1F* HFLightCal::hspe[26][36][2]
private

Definition at line 35 of file HFLightCal.h.

TH1F* HFLightCal::hspepin[8][3]
private

Definition at line 41 of file HFLightCal.h.

TH1F * HFLightCal::hspes
private

Definition at line 38 of file HFLightCal.h.

TH1F* HFLightCal::hsppin[8][3]
private

Definition at line 40 of file HFLightCal.h.

TH1F * HFLightCal::htmax
private

Definition at line 38 of file HFLightCal.h.

TH1F * HFLightCal::htmean
private

Definition at line 38 of file HFLightCal.h.

TH1F* HFLightCal::hts[26][36][2]
private

Definition at line 32 of file HFLightCal.h.

TH1F* HFLightCal::htsm[26][36][2]
private

Definition at line 33 of file HFLightCal.h.

TH1F* HFLightCal::htsmpin[8][3]
private

Definition at line 43 of file HFLightCal.h.

TH1F* HFLightCal::htspin[8][3]
private

Definition at line 39 of file HFLightCal.h.

TFile* HFLightCal::mFile
private

Definition at line 29 of file HFLightCal.h.

std::string HFLightCal::prefile
private

Definition at line 28 of file HFLightCal.h.

FILE* HFLightCal::preFile
private

Definition at line 31 of file HFLightCal.h.

std::string HFLightCal::textfile
private

Definition at line 27 of file HFLightCal.h.

FILE* HFLightCal::tFile
private

Definition at line 30 of file HFLightCal.h.