00001
00002
00003
00004
00005
00006
00007
00008 #include <memory>
00009 #include <string>
00010 #include <iostream>
00011
00012 #include "TH1F.h"
00013 #include "TH2F.h"
00014 #include "TFile.h"
00015 #include "math.h"
00016 #include "TMath.h"
00017 #include "TF1.h"
00018
00019 #include "CalibCalorimetry/HcalStandardModules/interface/HFLightCal.h"
00020
00021 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00022 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00023
00024 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00025 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00026 #include "CondFormats/HcalObjects/interface/HcalQIEShape.h"
00027 #include "CondFormats/HcalObjects/interface/HcalQIECoder.h"
00028
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00031 #include "FWCore/Framework/interface/EventSetup.h"
00032 #include "FWCore/Framework/interface/ESHandle.h"
00033
00034 using namespace std;
00035 Int_t Nev, runN=0, eventN=0;
00036 Int_t itsmax[26][36][2];
00037 Int_t itspinmax[8][3];
00038
00039 namespace {
00040
00041 bool verbose = false;
00042 }
00043
00044 HFLightCal::HFLightCal (const edm::ParameterSet& fConfiguration) {
00045
00046 histfile = fConfiguration.getUntrackedParameter<string>("rootFile");
00047 textfile = fConfiguration.getUntrackedParameter<string>("textFile");
00048 prefile = fConfiguration.getUntrackedParameter<string>("preFile");
00049 }
00050
00051 HFLightCal::~HFLightCal () {
00052
00053 }
00054
00055 void HFLightCal::beginJob() {
00056
00057 char htit[64];
00058 Int_t neta,nphi,ndepth,nmax,nquad,npin;
00059
00060 std::cout<<std::endl<<"HFLightCal beginJob: --> "<<std::endl;
00061
00062
00063 mFile = new TFile (histfile.c_str(),"RECREATE");
00064 if ((tFile = fopen(textfile.c_str(),"w"))==NULL) {
00065 printf("\nNo output textfile open\n\n");
00066 std::cout<<"Problem with output textFILE => exit"<<std::endl;
00067 exit(1);
00068 }
00069
00070 if ((preFile = fopen(prefile.c_str(),"r"))==NULL){
00071 printf("\nNo input pre-file open\n\n");
00072 std::cout<<"Problem with input textFILE => exit"<<std::endl;
00073 exit(1);
00074 }
00075 rewind(preFile);
00076 for (int i=0; i<1728; i++) {
00077 fscanf(preFile,"%d%d%d%d\r",&neta,&nphi,&ndepth,&nmax);
00078
00079 if (neta>=29 && neta<=41 && nphi<72 && nphi>0 && ndepth>0 && ndepth<=2)
00080 itsmax[neta-29][(nphi-1)/2][ndepth-1] = nmax;
00081 else if (neta<=-29 && neta>=-41 && nphi<72 && nphi>0 && ndepth>0 && ndepth<=2)
00082 itsmax[13-neta-29][(nphi-1)/2][ndepth-1] = nmax;
00083 else {
00084 std::cout<<"Input pre-file: wrong channel record:"<<std::endl;
00085 std::cout<<"eta="<<neta<<" phi="<<nphi<<" depth="<<ndepth<<" max="<<nmax<<std::endl;
00086 }
00087 }
00088 for (int i=0; i<24; i++) {
00089 fscanf(preFile,"%d%d%d\r",&nquad,&npin,&nmax);
00090
00091 if (nquad>0 && nquad<=4 && npin<=3 && npin>0)
00092 itspinmax[nquad-1][npin-1] = nmax;
00093 else if (nquad<0 && nquad>=-4 && npin<=3 && npin>0)
00094 itspinmax[4-nquad-1][npin-1] = nmax;
00095 else {
00096 std::cout<<"Input pre-file: wrong PIN record:"<<std::endl;
00097 std::cout<<"quad="<<nquad<<" pin="<<npin<<" max="<<nmax<<std::endl;
00098 }
00099 }
00100
00101
00102 htmax = new TH1F("htmax","Max TS",10,-0.5,9.5);
00103 htmean = new TH1F("htmean","Mean signal TS",100,0,10);
00104 hsignalmean = new TH1F("hsignalmean","Mean ADC 4maxTS",1201,-25,30000);
00105 hsignalrms = new TH1F("hsignalrms","RMS ADC 4maxTS",500,0,500);
00106 hpedmean = new TH1F("hpedmean","Mean ADC 4lowTS",200,-10,90);
00107 hpedrms = new TH1F("hpedrms","RMS ADC 4lowTS",200,0,100);
00108 hspes = new TH1F("hspes","SPE if measured",200,0,40);
00109 hnpevar = new TH1F("hnpevar","~N PE input",500,0,500);
00110 hsignalmapP = new TH2F("hsignalmapP","Mean(Response) - Mean(Pedestal) HFP;#eta;#phi",26,28.5,41.5,36,0,72);
00111 hsignalRMSmapP = new TH2F("hsignalRMSmapP","RMS Response HFP;#eta;#phi",26,28.5,41.5,36,0,72);
00112 hnpemapP = new TH2F("hnpemapP","~N PE input HFP;#eta;#phi",26,28.5,41.5,36,0,72);
00113 hnpemapP->SetOption("COLZ");hsignalmapP->SetOption("COLZ");hsignalRMSmapP->SetOption("COLZ");
00114 hsignalmapM = new TH2F("hsignalmapM","Mean(Response) - Mean(Pedestal) HFM;#eta;#phi",26,-41.5,-28.5,36,0,72);
00115 hsignalRMSmapM = new TH2F("hsignalRMSmapM","RMS Response HFM;#eta;#phi",26,-41.5,-28.5,36,0,72);
00116 hnpemapM = new TH2F("hnpemapM","~N PE input HFM;#eta;#phi",26,-41.5,-28.5,36,0,72);
00117 hnpemapM->SetOption("COLZ");hsignalmapM->SetOption("COLZ");hsignalRMSmapM->SetOption("COLZ");
00118
00119 for (int i=0;i<13;i++) for (int j=0;j<36;j++) for (int k=0;k<2;k++) {
00120 if (i>10 && j%2==0) continue;
00121 sprintf(htit,"ts_+%d_%d_%d",i+29,j*2+1,k+1);
00122 hts[i][j][k] = new TH1F(htit,htit,10,-0.5,9.5);
00123 sprintf(htit,"tsmean_+%d_%d_%d",i+29,j*2+1,k+1);
00124 htsm[i][j][k] = new TH1F(htit,htit,100,0,10);
00125 sprintf(htit,"sp_+%d_%d_%d",i+29,j*2+1,k+1);
00126 hsp[i][j][k] = new TH1F(htit,htit,1201,-25,30000);
00127 sprintf(htit,"spe_+%d_%d_%d",i+29,j*2+1,k+1);
00128 hspe[i][j][k] = new TH1F(htit,htit,200,-9.5,190.5);
00129 sprintf(htit,"ped_+%d_%d_%d",i+29,j*2+1,k+1);
00130 hped[i][j][k] = new TH1F(htit,htit,200,-9.5,190.5);
00131 sprintf(htit,"ts_-%d_%d_%d",i+29,j*2+1,k+1);
00132 hts[i+13][j][k] = new TH1F(htit,htit,10,-0.5,9.5);
00133 sprintf(htit,"tsmean_-%d_%d_%d",i+29,j*2+1,k+1);
00134 htsm[i+13][j][k] = new TH1F(htit,htit,100,0,10);
00135 sprintf(htit,"sp_-%d_%d_%d",i+29,j*2+1,k+1);
00136 hsp[i+13][j][k] = new TH1F(htit,htit,1201,-25,30000);
00137 sprintf(htit,"spe_-%d_%d_%d",i+29,j*2+1,k+1);
00138 hspe[i+13][j][k] = new TH1F(htit,htit,200,-9.5,190.5);
00139 sprintf(htit,"ped_-%d_%d_%d",i+29,j*2+1,k+1);
00140 hped[i+13][j][k] = new TH1F(htit,htit,200,-9.5,190.5);
00141 }
00142
00143 for (int i=0;i<4;i++) for (int j=0;j<3;j++) {
00144 sprintf(htit,"ts_PIN%d_+Q%d",j+1,i+1);
00145 htspin[i][j] = new TH1F(htit,htit,10,-0.5,9.5);
00146 sprintf(htit,"sp_PIN%d_+Q%d",j+1,i+1);
00147 hsppin[i][j] = new TH1F(htit,htit,1601,-25,40000);
00148 sprintf(htit,"spe_PIN%d_+Q%d",j+1,i+1);
00149 hspepin[i][j] = new TH1F(htit,htit,200,-9.5,190.5);
00150 sprintf(htit,"ped_PIN%d_+Q%d",j+1,i+1);
00151 hpedpin[i][j] = new TH1F(htit,htit,200,-9.5,190.5);
00152 sprintf(htit,"tsmean_PIN%d_+Q%d",j+1,i+1);
00153 htsmpin[i][j] = new TH1F(htit,htit,100,0,10);
00154 sprintf(htit,"ts_PIN%d_-Q%d",j+1,i+1);
00155 htspin[i+4][j] = new TH1F(htit,htit,10,-0.5,9.5);
00156 sprintf(htit,"sp_PIN%d_-Q%d",j+1,i+1);
00157 hsppin[i+4][j] = new TH1F(htit,htit,1601,-25,40000);
00158 sprintf(htit,"spe_PIN%d_-Q%d",j+1,i+1);
00159 hspepin[i+4][j] = new TH1F(htit,htit,200,-9.5,190.5);
00160 sprintf(htit,"ped_PIN%d_-Q%d",j+1,i+1);
00161 hpedpin[i+4][j] = new TH1F(htit,htit,200,-9.5,190.5);
00162 sprintf(htit,"tsmean_PIN%d_-Q%d",j+1,i+1);
00163 htsmpin[i+4][j] = new TH1F(htit,htit,100,0,10);
00164 }
00165 std::cout<<std::endl<<"histfile="<<histfile.c_str()<<" textfile="<<textfile.c_str()<<std::endl;
00166 return;
00167 }
00168
00169 void HistSpecs(TH1F* hist, Double_t &mean, Double_t &rms, Double_t range=4) {
00170 Double_t xmin,xmax;
00171 mean=hist->GetMean();
00172 rms=hist->GetRMS();
00173 xmin=hist->GetXaxis()->GetXmin();
00174 xmax=hist->GetXaxis()->GetXmax();
00175 hist->SetAxisRange(mean-range*rms-100,mean+range*rms+100);
00176 mean=hist->GetMean();
00177 rms=hist->GetRMS();
00178 hist->SetAxisRange(mean-range*rms-100,mean+range*rms+100);
00179 mean=hist->GetMean();
00180 rms=hist->GetRMS();
00181 hist->SetAxisRange(xmin,xmax);
00182 return;
00183 }
00184
00185 Double_t FitFun(Double_t *x, Double_t *par) {
00186
00187
00188 Double_t sum,xx,A0,C0,r0,sigma0,mean1,sigma1,A1,C1,r1,mean2,sigma2,A2,C2,r2,mean3,sigma3,A3,C3,r3;
00189
00190 const Double_t k0=2.0, k1=1.6, k2=2.0;
00191
00192 xx=x[0];
00193 sigma0 = par[2];
00194 A0 = 2*Nev/(2+2*par[0]+par[0]*par[0]+pow(par[0],3)/3+pow(par[0],4)/12+
00195 pow(par[0],5)/60+pow(par[0],6)/360);
00196 r0 = ((xx-par[1])/sigma0);
00197 C0 = 1/(sigma0* TMath::Exp(-k0*k0/2)/k0 +
00198 sigma0*sqrt(2*3.14159)*0.5*(1+TMath::Erf(k0/1.41421)));
00199
00200 if(r0 < k0) sum = C0*A0*TMath::Exp(-0.5*r0*r0);
00201 else sum = C0*A0*TMath::Exp(0.5*k0*k0-k0*r0);
00202
00203 mean1 = par[1]+par[3];
00204 sigma1 = par[4];
00205
00206
00207 A1 = A0*par[0];
00208 C1 = 1/(sigma1* TMath::Exp(-k1*k1/2)/k1 +
00209 sigma1*sqrt(2*3.14159)*0.5*(1+TMath::Erf(k1/1.41421)));
00210 r1 = ((xx-mean1)/sigma1);
00211 if(r1 < k1) sum += C1*A1*TMath::Exp(-0.5*r1*r1);
00212 else sum += C1*A1*TMath::Exp(0.5*k1*k1-k1*r1);
00213
00214 mean2 = 2*par[3]+par[1];
00215 sigma2 = sqrt(2*sigma1*sigma1 - pow(par[2],2));
00216
00217 A2 = A0*par[0]*par[0]/2;
00218 C2 = 1/(sigma2* TMath::Exp(-k2*k2/2)/k2 +
00219 sigma2*sqrt(2*3.14159)*0.5*(1+TMath::Erf(k2/1.41421)));
00220 r2 = ((xx-mean2)/sigma2);
00221 if(r2 < k2) sum += C2*A2*TMath::Exp(-0.5*r2*r2);
00222 else sum += C2*A2*TMath::Exp(0.5*k2*k2-k2*r2);
00223
00224 mean3 = 3*par[3]+par[1];
00225 sigma3 = sqrt(3*sigma1*sigma1 - 2*pow(par[2],2));
00226 A3 = A0*par[0]*par[0]*par[0]/6;
00227 C3 = 1/(sigma3*sqrt(2*3.14159));
00228 r3 = ((xx-mean3)/sigma3);
00229 sum += C3*A3*TMath::Exp(-0.5*r3*r3);
00230
00231 return sum;
00232 }
00233
00234 void HFLightCal::endJob(void)
00235 {
00236 Double_t mean,rms,meanped,rmsped,npevar;
00237 Double_t par[5],dspe=0,dnpe;
00238 Int_t tsmax,intspe;
00239 std::cout<<std::endl<<"HFLightCal endJob --> ";
00240 fprintf(tFile,"#RunN %d Events processed %d",runN,eventN);
00241
00242 for (int i=0;i<26;i++) for (int j=0;j<36;j++) for (int k=0;k<2;k++) {
00243 if (i>10 && i<13 && j%2==0) continue;
00244 if (i>23 && j%2==0) continue;
00245 meanped=rmsped=mean=rms=0;
00246 if (hsp[i][j][k]->Integral()>0) {
00247 HistSpecs(hped[i][j][k],meanped,rmsped);
00248 HistSpecs(hsp[i][j][k],mean,rms);
00249 if (hspe[i][j][k]->Integral()>hsp[i][j][k]->Integral()*0.9 || mean<100) {
00250 HistSpecs(hspe[i][j][k],mean,rms);
00251 }
00252 hsignalmean->Fill(mean);
00253 hsignalrms->Fill(rms);
00254 hpedmean->Fill(meanped);
00255 hpedrms->Fill(rmsped);
00256 }
00257 }
00258
00259 meanped=hpedmean->GetMean();
00260 rmsped=hpedrms->GetMean();
00261 mean=hsignalmean->GetMean();
00262 rms=hsignalrms->GetMean();
00263 fprintf(tFile," MeanInput=<%.2f> [linADCcount] RMS=<%.2f>\n",mean,rms);
00264 fprintf(tFile,"#eta/phi/depth sum4maxTS RMS ~N_PE sum4lowTS RMS maxTS SPE +/- Err Comment\n");
00265 TF1* fPed = new TF1("fPed","gaus",0,120);
00266 fPed->SetNpx(200);
00267 TF1 *fTot = new TF1("fTot",FitFun ,0,200,5);
00268 fTot->SetNpx(800);
00269 for (int i=0;i<26;i++) for (int j=0;j<36;j++) for (int k=0;k<2;k++) {
00270 if (i>10 && i<13 && j%2==0) continue;
00271 if (i>23 && j%2==0) continue;
00272 HistSpecs(hped[i][j][k],meanped,rmsped);
00273 HistSpecs(hsp[i][j][k],mean,rms);
00274 par[3]=0;
00275 if (hspe[i][j][k]->Integral()>hsp[i][j][k]->Integral()*0.9 || mean<100) {
00276 HistSpecs(hspe[i][j][k],mean,rms);
00277 if (hspe[i][j][k]->Integral(1,(int) (meanped+3*rmsped+12))/Nev>0.1) {
00278
00279 if (mean+rms*3-meanped-rmsped*3>2 && rmsped>0) {
00280 par[1] = meanped;
00281 par[2] = rmsped;
00282 par[0] = hped[i][j][k]->GetMaximum();
00283 fPed->SetParameters(par);
00284 hped[i][j][k]->Fit(fPed,"BQ0");
00285 fPed->GetParameters(&par[0]);
00286 hped[i][j][k]->Fit(fPed,"B0Q","",par[1]-par[2]*3,par[1]+par[2]*3);
00287 fPed->GetParameters(par);
00288 hped[i][j][k]->Fit(fPed,"BLIQ","",par[1]-par[2]*3,par[1]+par[2]*3);
00289 fPed->GetParameters(&par[0]);
00290 Nev = (int) hspe[i][j][k]->Integral();
00291 par[0]=0.1;
00292 par[3]=10;
00293 par[4]=6;
00294 fTot->SetParameters(par);
00295 fTot->SetParLimits(0,0,2);
00296
00297 fTot->SetParLimits(1,par[1]-1,par[1]+1);
00298 fTot->FixParameter(2,par[2]);
00299 fTot->SetParLimits(3,1.2,100);
00300
00301
00302 hspe[i][j][k]->Fit(fTot,"BLEQ","");
00303 fTot->GetParameters(par);
00304 hspe[i][j][k]->Fit(fTot,"BLEQ","",-10,par[1]+par[3]*5);
00305 fTot->GetParameters(par);
00306 dspe=fTot->GetParError(3);
00307 dnpe=fTot->GetParError(0);
00308 if (par[3]<1.21 || dnpe>par[0]) par[3]=-1;
00309 else if (par[0]>1.96 || par[3]>49) par[3]=0;
00310 else {
00311 hspes->Fill(par[3]);
00312 }
00313 }
00314 }
00315 }
00316
00317
00318 npevar=0;
00319 if (par[3]>0) npevar=par[0];
00320 else {
00321 if (hspe[i][j][k]->Integral()>hsp[i][j][k]->Integral()*0.98) {
00322 HistSpecs(hspe[i][j][k],mean,rms,3);
00323 }
00324 else {
00325 HistSpecs(hsp[i][j][k],mean,rms,3);
00326 }
00327 if (rmsped>0) {
00328 if (rms*rms-rmsped*rmsped>1 && mean>meanped) {
00329 npevar=(mean-meanped)*(mean-meanped)/(rms*rms-rmsped*rmsped);
00330 }
00331 else if (mean<100) {
00332 intspe=int(hspe[i][j][k]->Integral());
00333 hspe[i][j][k]->SetAxisRange(meanped+rmsped*4,300);
00334 npevar=hspe[i][j][k]->Integral()/intspe;
00335 if (npevar>0.01) npevar=-1;
00336 else npevar=0;
00337 hspe[i][j][k]->SetAxisRange(-20,300);
00338 }
00339 }
00340 }
00341 if (npevar>5.0e-5) hnpevar->Fill(npevar);
00342
00343 if (i<13) {
00344 hsignalmapP->Fill(i+28.6+k/2.0,j*2+1,mean-meanped);
00345 hsignalRMSmapP->Fill(i+28.6+k/2.0,j*2+1,rms);
00346 if (npevar>0) hnpemapP->Fill(i+28.6+k/2.0,j*2+1,npevar);
00347 fprintf(tFile,"%3d%4d%5d %11.2f%8.2f",i+29,j*2+1,k+1,mean,rms);
00348 }
00349 else {
00350 fprintf(tFile,"%3d%4d%5d %11.2f%8.2f",13-i-29,j*2+1,k+1,mean,rms);
00351 hsignalmapM->Fill(13-i-28.6-k/2.0,j*2+1,mean-meanped);
00352 hsignalRMSmapM->Fill(13-i-28.6-k/2.0,j*2+1,rms);
00353 if (npevar>0) hnpemapM->Fill(13-i-28.6-k/2.0,j*2+1,npevar);
00354 }
00355 if (npevar>0) fprintf(tFile," %9.4f",npevar);
00356 else fprintf(tFile," 0 ");
00357 fprintf(tFile," %8.2f%8.2f",meanped,rmsped);
00358 tsmax=hts[i][j][k]->GetMaximumBin()-1;
00359 fprintf(tFile," %4d",tsmax);
00360 if (par[3]>0 && par[3]<99) fprintf(tFile,"%8.2f%7.2f",par[3],dspe);
00361 else if (npevar>0) fprintf(tFile,"%8.2f 0 ",(mean-meanped)/npevar);
00362 else fprintf(tFile," 0 0 ");
00363
00364
00365 fprintf(tFile," ");
00366 if (hsp[i][j][k]->GetEntries()<=0) fprintf(tFile,"NoSignal\n");
00367 else if (hsp[i][j][k]->GetEntries()<=10) fprintf(tFile,"Nev<10\n");
00368 else {
00369 if (hsp[i][j][k]->Integral()<=10 || mean>12000) fprintf(tFile,"SignalOffRange\n");
00370 else {
00371 if (hsp[i][j][k]->Integral()<100) fprintf(tFile,"Nev<100/");
00372 if (npevar>0 && par[3]>0 && (npevar*Nev<10 || npevar<0.001))
00373 fprintf(tFile,"LowSignal/");
00374 else if (npevar==0 && fabs(mean-meanped)<3) fprintf(tFile,"LowSignal/");
00375 if (par[3]<0) fprintf(tFile,"BadFit/");
00376 else if (par[3]==0) fprintf(tFile,"NoSPEFit/");
00377 else if (par[3]>0 && npevar>1) fprintf(tFile,"NPE>1/");
00378 if (npevar<0) fprintf(tFile,"Problem/");
00379 if (mean<2) fprintf(tFile,"LowMean/");
00380 if (rms<0.5) fprintf(tFile,"LowRMS/");
00381 if (meanped<-1) fprintf(tFile,"LowPed/");
00382 else if (meanped>25) fprintf(tFile,"HighPed/");
00383 if (rmsped<0.5 && rmsped>0) fprintf(tFile,"NarrowPed/");
00384 else if (rmsped>10) fprintf(tFile,"WidePed/");
00385 if (hped[i][j][k]->GetBinContent(201)>10) fprintf(tFile,"PedOffRange");
00386 fprintf(tFile,"-\n");
00387 }
00388 }
00389 }
00390
00391 for (int i=0;i<8;i++) for (int j=0;j<3;j++) {
00392 HistSpecs(hpedpin[i][j],meanped,rmsped);
00393 HistSpecs(hsppin[i][j],mean,rms);
00394 if (hspepin[i][j]->Integral()>hsppin[i][j]->Integral()*0.9 || mean<100) {
00395 HistSpecs(hspepin[i][j],mean,rms);
00396 }
00397 if (i<4) fprintf(tFile," PIN%d +Q%d %12.2f %6.2f",j+1,i+1,mean,rms);
00398 else fprintf(tFile," PIN%d -Q%d %12.2f %6.2f",j+1,i-3,mean,rms);
00399 fprintf(tFile," %15.2f %6.2f",meanped,rmsped);
00400 tsmax=htspin[i][j]->GetMaximumBin()-1;
00401 fprintf(tFile," %4d\n",tsmax);
00402 }
00403
00404 mFile->Write();
00405 mFile->Close();
00406 fclose(tFile);
00407 std::cout<<std::endl<<" --endJob-- done"<<std::endl;
00408 return;
00409 }
00410
00411 void HFLightCal::analyze(const edm::Event& fEvent, const edm::EventSetup& fSetup) {
00412
00413
00414 edm::EventID eventId = fEvent.id();
00415 int runNer = eventId.run ();
00416 int eventNumber = eventId.event ();
00417 if (runN==0) runN=runNer;
00418 eventN++;
00419 if (verbose) std::cout << "========================================="<<std::endl
00420 << "run/event: "<<runNer<<'/'<<eventNumber<<std::endl;
00421
00422 Double_t buf[20];
00423 Double_t maxADC,signal,ped=0,meant;
00424 Int_t maxisample=0,i1=3,i2=6;
00425
00426
00427 edm::Handle<HcalCalibDigiCollection> calib;
00428 fEvent.getByType(calib);
00429 if (verbose) std::cout<<"Analysis-> total CAL digis= "<<calib->size()<<std::endl;
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483 edm::Handle<HFDigiCollection> hf_digi;
00484 fEvent.getByType(hf_digi);
00485 if (verbose) std::cout<<"Analysis-> total HF digis= "<<hf_digi->size()<<std::endl;
00486
00487 for (unsigned ihit = 0; ihit < hf_digi->size (); ++ihit) {
00488 const HFDataFrame& frame = (*hf_digi)[ihit];
00489 HcalDetId detId = frame.id();
00490 int ieta = detId.ieta();
00491 int iphi = detId.iphi();
00492 int depth = detId.depth();
00493 if (verbose) std::cout <<"HF digi # " <<ihit<<": eta/phi/depth: "
00494 <<ieta<<'/'<<iphi<<'/'<< depth << std::endl;
00495
00496 if (ieta>0) ieta = ieta-29;
00497 else ieta = 13-ieta-29;
00498
00499 maxADC=-99;
00500 for (int isample = 0; isample < frame.size(); ++isample) {
00501 int adc = frame[isample].adc();
00502 int capid = frame[isample].capid ();
00503 double linear_ADC = frame[isample].nominal_fC();
00504 double nominal_fC = detId.subdet () == HcalForward ? 2.6 * linear_ADC : linear_ADC;
00505
00506 if (verbose) std::cout << "Analysis-> HF sample # " << isample
00507 << ", capid=" << capid
00508 << ": ADC=" << adc
00509 << ", linearized ADC=" << linear_ADC
00510 << ", nominal fC=" << nominal_fC <<std::endl;
00511
00512 hts[ieta][(iphi-1)/2][depth-1]->Fill(isample,linear_ADC);
00513 buf[isample]=linear_ADC;
00514
00515
00516
00517
00518
00519
00520 }
00521
00522 maxADC=-99;
00523 for (int ii=0; ii<10; ii++) {
00524 signal=buf[ii];
00525 if (ii<2) signal -= (buf[ii+4]+buf[ii+8])/2.0;
00526 else if (ii<4) signal -= buf[ii+4];
00527 else if (ii<6) signal -= (buf[ii+4]+buf[ii-4])/2.0;
00528 else if (ii<8) signal -= buf[ii-4];
00529 else signal -= (buf[ii-4]+buf[ii-8])/2.0;
00530 if (signal>maxADC) {
00531 maxADC=signal;
00532 maxisample=ii;
00533 }
00534 }
00535
00536 if (abs(maxisample-itsmax[ieta][(iphi-1)/2][depth-1]+1)>1) maxisample=itsmax[ieta][(iphi-1)/2][depth-1]-1;
00537 if (verbose) std::cout<<eventNumber<<"/"<<ihit<<": maxTS="<<maxisample<<endl;
00538
00539
00540 htmax->Fill(maxisample);
00541 i1=maxisample-1;
00542 i2=maxisample+2;
00543 if (i1<0) {i1=0;i2=3;}
00544 else if (i2>9) {i1=6;i2=9;}
00545 else if (i2<9 && maxisample<=itsmax[ieta][(iphi-1)/2][depth-1]-1) {
00546 if (buf[i1]<buf[i2+1]) {i1=i1+1;i2=i2+1;}
00547 }
00548 signal=buf[i1]+buf[i1+1]+buf[i1+2]+buf[i1+3];
00549 hsp[ieta][(iphi-1)/2][depth-1]->Fill(signal);
00550 hspe[ieta][(iphi-1)/2][depth-1]->Fill(signal);
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561 if (i1<2) ped=buf[8]+buf[9]+buf[6]+buf[7];
00562 else if (i1==2) ped=buf[6]+buf[9]+buf[7]+buf[0];
00563 else if (i1==3) ped=buf[0]+buf[1]+buf[2]+buf[7];
00564 else if (i1>=4) ped=buf[0]+buf[1]+buf[2]+buf[3];
00565
00566 hped[ieta][(iphi-1)/2][depth-1]->Fill(ped);
00567
00568
00569 ped=ped/4;
00570 meant=(buf[i1]-ped)*i1+(buf[i1+1]-ped)*(i1+1)+(buf[i1+2]-ped)*(i1+2)+(buf[i1+3]-ped)*(i1+3);
00571 meant /= (buf[i1]-ped)+(buf[i1+1]-ped)+(buf[i1+2]-ped)+(buf[i1+3]-ped);
00572 htmean->Fill(meant);
00573 htsm[ieta][(iphi-1)/2][depth-1]->Fill(meant);
00574 }
00575 }
00576