27 init(alpha0, beta0, width0, chi20);
32 init(tAB, alpha0, beta0, width0, chi20);
44 for(
int cris=0;cris<
fNchsel;cris++){
50 alpha_val[cris]=alpha0;
52 width_val[cris]=width0;
56 alpha_init[cris]=alpha0;
57 beta_init[cris]=beta0;
58 width_init[cris]=width0;
59 chi2_init[cris]=chi20;
68 assignChannel(cris,cris);
75 init( alpha0, beta0, width0, chi20 );
77 tABinit=tAB->CloneTree();
107 tABinit->SetBranchAddress(
"iphi", &iphii, &b_iphi);
108 tABinit->SetBranchAddress(
"ieta", &ietai, &b_ieta);
109 tABinit->SetBranchAddress(
"side", &sidei, &b_side);
110 tABinit->SetBranchAddress(
"dccID", &dccIDi, &b_dccID);
111 tABinit->SetBranchAddress(
"towerID", &towerIDi, &b_towerID);
112 tABinit->SetBranchAddress(
"channelID", &channelIDi, &b_channelID);
113 tABinit->SetBranchAddress(
"alpha", &alphai, &b_alpha);
114 tABinit->SetBranchAddress(
"beta", &betai, &b_beta);
115 tABinit->SetBranchAddress(
"width", &widthi, &b_width);
116 tABinit->SetBranchAddress(
"chi2", &chi2i, &b_chi2);
117 tABinit->SetBranchAddress(
"flag", &flagi, &b_flag);
119 nchsel=tABinit->GetEntries();
122 for(
int cris=0;cris<nchsel;cris++){
124 tABinit->GetEntry(cris);
128 putalphaVal(cris,alphai);
129 putchi2Val(cris,chi2i);
130 putbetaVal(cris,betai);
131 putwidthVal(cris,widthi);
132 putflagVal(cris,flagi);
134 putalphaInit(cris,alphai);
135 putchi2Init(cris,chi2i);
136 putbetaInit(cris,betai);
137 putwidthInit(cris,widthi);
138 putflagInit(cris,flagi);
139 putetaInit(cris,ietai);
140 putphiInit(cris,iphii);
165 if(tABinit)
assert(nch==nchsel);
172 printf(
" number of channels exceed maximum allowed\n");
191 timestart= ((
long int) timecur);
198 timestop= ((
long int) timecur);
209 putAllVals(ch, sampl, ieta, iphi);
218 for(i=0;i<nchsel;i++)
222 if(npass[n] < nevt) {
224 for(k=0;k<nsamplecristal;k++) {
225 rawsglu[
n][npass[
n]][
k] = sampl[
k];
231 printf(
"no index found for ch=%d\n",ch);
238 double tm_atmax[200];
244 dbi =
new double *[200];
245 for(
int k=0;
k<200;
k++) dbi[
k] =
new double[2];
248 signalu =
new double *[200];
249 for(
int k=0 ;
k<200;
k++) signalu[
k] =
new double[10];
253 for(
int i=0;
i<nchsel;
i++) {
259 putalphaVal(
i, alpha_init[
i]);
260 putbetaVal(i, beta_init[i]);
261 putwidthVal(i,width_init[i]);
262 putchi2Val(i,chi2_init[i]);
267 pjf->
set_const(nsamplecristal, sampbmax, sampamax, alpha_init[
i], beta_init[i], npass[i]);
269 for(
int pass=0;pass<npass[
i];pass++){
272 for(
int k=0;
k<presample;
k++) {
273 ped+= rawsglu[
i][pass][
k];
275 ped/=double(presample);
277 for(
int k=0;
k<nsamplecristal;
k++) {
278 signalu[pass][
k]= rawsglu[
i][pass][
k]-ped;
283 chi2_all= pjf->
fitpj(signalu,&parout[0],dbi,
noise, debug);
285 if(parout[0]>=0.0 && parout[1]>=0.0 && chi2_all<=chi2cut && chi2_all>0.0){
287 putalphaVal(i,parout[0]);
288 putbetaVal(i,parout[1]);
289 putchi2Val(i,chi2_all);
294 putalphaVal(i,alpha_init[i]);
295 putbetaVal(i,beta_init[i]);
296 putwidthVal(i,width_init[i]);
297 putchi2Val(i,chi2_init[i]);
302 for(
int kj=0;kj<npass[
i];kj++) {
303 tm_atmax[kj]= dbi[kj][1];
305 computetmaxVal(i,&tm_atmax[0]);
311 if(tAB) tABinit=tAB->CloneTree();
332 TBranch *b_channelID;
341 tABinit->SetBranchAddress(
"iphi", &iphii, &b_iphi);
342 tABinit->SetBranchAddress(
"ieta", &ietai, &b_ieta);
343 tABinit->SetBranchAddress(
"side", &sidei, &b_side);
344 tABinit->SetBranchAddress(
"dccID", &dccIDi, &b_dccID);
345 tABinit->SetBranchAddress(
"towerID", &towerIDi, &b_towerID);
346 tABinit->SetBranchAddress(
"channelID", &channelIDi, &b_channelID);
347 tABinit->SetBranchAddress(
"alpha", &alphai, &b_alpha);
348 tABinit->SetBranchAddress(
"beta", &betai, &b_beta);
349 tABinit->SetBranchAddress(
"width", &widthi, &b_width);
350 tABinit->SetBranchAddress(
"chi2", &chi2i, &b_chi2);
351 tABinit->SetBranchAddress(
"flag", &flagi, &b_flag);
354 TFile *fABout =
new TFile(namefile.c_str(),
"RECREATE");
355 tABout=
new TTree(
"ABCol0",
"ABCol0");
370 tABout->Branch(
"iphi", &iphi,
"iphi/I" );
371 tABout->Branch(
"ieta", &ieta,
"ieta/I" );
372 tABout->Branch(
"side", &side,
"side/I" );
373 tABout->Branch(
"dccID", &dccID,
"dccID/I" );
374 tABout->Branch(
"towerID", &towerID,
"towerID/I" );
375 tABout->Branch(
"channelID", &channelID,
"channelID/I" );
376 tABout->Branch(
"alpha", &alpha,
"alpha/D" );
377 tABout->Branch(
"beta", &beta,
"beta/D" );
378 tABout->Branch(
"width", &width,
"width/D" );
379 tABout->Branch(
"chi2", &chi2,
"chi2/D" );
380 tABout->Branch(
"flag", &flag,
"flag/I" );
382 tABout->SetBranchAddress(
"ieta", &ieta );
383 tABout->SetBranchAddress(
"iphi", &iphi );
384 tABout->SetBranchAddress(
"side", &side );
385 tABout->SetBranchAddress(
"dccID", &dccID );
386 tABout->SetBranchAddress(
"towerID", &towerID );
387 tABout->SetBranchAddress(
"channelID", &channelID );
388 tABout->SetBranchAddress(
"alpha", &alpha );
389 tABout->SetBranchAddress(
"beta", &beta );
390 tABout->SetBranchAddress(
"width", &width );
391 tABout->SetBranchAddress(
"chi2", &chi2 );
392 tABout->SetBranchAddress(
"flag", &flag );
394 for(
int i=0;
i<nchsel;
i++) {
398 tABinit->GetEntry(
i);
404 channelID=channelIDi;
412 towerID=tower_init[
i];
413 channelID=ch_init[
i];
437 double tm=0.;
double sigtm=0.;
438 for(
int k=0;
k<npass[
i]-1;
k++) {
439 if(1. < tm_val[
k] && tm_val[
k] < 10.) {
442 sigtm+= tm_val[
k]*tm_val[
k];
445 if(npassok[i] <= 0) {
448 for(
int k=0;
k<npass[
i]-1;
k++) {
449 if(1. < tm_val[
k] && tm_val[
k] < 10.) {
450 double ss= (sigtm/npassok[
i]-tm/npassok[
i]*tm/npassok[
i]);
453 tm_mean= tm/npassok[
i];
458 putwidthVal(i,tm_mean);
522 std::vector<double>
v;
524 v.push_back(alpha_val[n]);
525 v.push_back(beta_val[n]);
526 v.push_back(width_val[n]);
527 v.push_back(chi2_val[n]);
528 v.push_back(flag_val[n]);
535 std::vector<double>
v;
537 v.push_back(alpha_init[n]);
538 v.push_back(beta_init[n]);
539 v.push_back(width_init[n]);
540 v.push_back(chi2_init[n]);
541 v.push_back(flag_init[n]);
550 sprintf(
filename,
"runABW%d.pedestal",gRunNumber);
552 if(fd ==
NULL) printf(
"Error while opening file : %s\n",
filename);
554 for(
int i=0;
i<nchsel;
i++) {
556 nev= (int) npassok[
i];
557 double trise= alpha_val[
i]*beta_val[
i];
558 fprintf( fd,
"%d %d 1 %ld %ld %f %f %f %f\n",
559 index[
i],nev,timestart,timestop,alpha_val[i],beta_val[i],trise,width_val[i]);
563 printf(
" Closing file : %d\n",iret);
void putbetaInit(int, double)
void putchi2Val(int, double)
void putwidthVal(int, double)
void putflagVal(int, int)
virtual ~TShapeAnalysis()
void putDateStart(long int)
void init(double, double, double, double)
void computeShape(std::string namefile, TTree *)
void putAllVals(int, double *, int, int)
void putbetaVal(int, double)
void putDateStop(long int)
TShapeAnalysis(double, double, double, double)
void assignChannel(int, int)
void putetaInit(int, int)
void set_const(int, int, int, double, double, int)
void putflagInit(int, int)
std::vector< double > getInitVals(int)
void putalphaVal(int, double)
void putchi2Init(int, double)
void putalphaInit(int, double)
void putwidthInit(int, double)
std::vector< double > getVals(int)
void set_const(int, int, int, int, int, double, double)
void computetmaxVal(int, double *)
EcalLogicID towerID(EcalElectronicsId const &)
double fitpj(double **, double *, double **, double noise_val, int debug)
void putphiInit(int, int)