28 init(alpha0, beta0, width0, chi20);
33 init(tAB, alpha0, beta0, width0, chi20);
45 for(
int cris=0;cris<
fNchsel;cris++){
51 alpha_val[cris]=alpha0;
53 width_val[cris]=width0;
57 alpha_init[cris]=alpha0;
58 beta_init[cris]=beta0;
59 width_init[cris]=width0;
60 chi2_init[cris]=chi20;
69 assignChannel(cris,cris);
76 init( alpha0, beta0, width0, chi20 );
78 tABinit=tAB->CloneTree();
108 tABinit->SetBranchAddress(
"iphi", &iphii, &b_iphi);
109 tABinit->SetBranchAddress(
"ieta", &ietai, &b_ieta);
110 tABinit->SetBranchAddress(
"side", &sidei, &b_side);
111 tABinit->SetBranchAddress(
"dccID", &dccIDi, &b_dccID);
112 tABinit->SetBranchAddress(
"towerID", &towerIDi, &b_towerID);
113 tABinit->SetBranchAddress(
"channelID", &channelIDi, &b_channelID);
114 tABinit->SetBranchAddress(
"alpha", &alphai, &b_alpha);
115 tABinit->SetBranchAddress(
"beta", &betai, &b_beta);
116 tABinit->SetBranchAddress(
"width", &widthi, &b_width);
117 tABinit->SetBranchAddress(
"chi2", &chi2i, &b_chi2);
118 tABinit->SetBranchAddress(
"flag", &flagi, &b_flag);
120 nchsel=tABinit->GetEntries();
123 for(
int cris=0;cris<nchsel;cris++){
125 tABinit->GetEntry(cris);
129 putalphaVal(cris,alphai);
130 putchi2Val(cris,chi2i);
131 putbetaVal(cris,betai);
132 putwidthVal(cris,widthi);
133 putflagVal(cris,flagi);
135 putalphaInit(cris,alphai);
136 putchi2Init(cris,chi2i);
137 putbetaInit(cris,betai);
138 putwidthInit(cris,widthi);
139 putflagInit(cris,flagi);
140 putetaInit(cris,ietai);
141 putphiInit(cris,iphii);
166 if(tABinit) assert(nch==nchsel);
173 printf(
" number of channels exceed maximum allowed\n");
192 timestart= ((
long int) timecur);
199 timestop= ((
long int) timecur);
210 putAllVals(ch, sampl, ieta, iphi);
219 for(i=0;i<nchsel;i++)
223 if(
npass[n] < nevt) {
225 for(k=0;k<nsamplecristal;k++) {
232 printf(
"no index found for ch=%d\n",ch);
239 double tm_atmax[200];
245 dbi =
new double *[200];
246 for(
int k=0;
k<200;
k++) dbi[
k] =
new double[2];
249 signalu =
new double *[200];
250 for(
int k=0 ;
k<200;
k++) signalu[
k] =
new double[10];
254 for(
int i=0;
i<nchsel;
i++) {
260 putalphaVal(
i, alpha_init[
i]);
261 putbetaVal(i, beta_init[i]);
262 putwidthVal(i,width_init[i]);
263 putchi2Val(i,chi2_init[i]);
268 pjf->
set_const(nsamplecristal, sampbmax, sampamax, alpha_init[
i], beta_init[i],
npass[i]);
270 for(
int pass=0;pass<
npass[
i];pass++){
273 for(
int k=0;
k<presample;
k++) {
274 ped+= rawsglu[
i][pass][
k];
276 ped/=double(presample);
278 for(
int k=0;
k<nsamplecristal;
k++) {
279 signalu[pass][
k]= rawsglu[
i][pass][
k]-ped;
284 chi2_all= pjf->
fitpj(signalu,&parout[0],dbi,noise, debug);
286 if(parout[0]>=0.0 && parout[1]>=0.0 && chi2_all<=chi2cut && chi2_all>0.0){
288 putalphaVal(i,parout[0]);
289 putbetaVal(i,parout[1]);
290 putchi2Val(i,chi2_all);
295 putalphaVal(i,alpha_init[i]);
296 putbetaVal(i,beta_init[i]);
297 putwidthVal(i,width_init[i]);
298 putchi2Val(i,chi2_init[i]);
303 for(
int kj=0;kj<npass[
i];kj++) {
304 tm_atmax[kj]= dbi[kj][1];
306 computetmaxVal(i,&tm_atmax[0]);
312 if(tAB) tABinit=tAB->CloneTree();
333 TBranch *b_channelID;
342 tABinit->SetBranchAddress(
"iphi", &iphii, &b_iphi);
343 tABinit->SetBranchAddress(
"ieta", &ietai, &b_ieta);
344 tABinit->SetBranchAddress(
"side", &sidei, &b_side);
345 tABinit->SetBranchAddress(
"dccID", &dccIDi, &b_dccID);
346 tABinit->SetBranchAddress(
"towerID", &towerIDi, &b_towerID);
347 tABinit->SetBranchAddress(
"channelID", &channelIDi, &b_channelID);
348 tABinit->SetBranchAddress(
"alpha", &alphai, &b_alpha);
349 tABinit->SetBranchAddress(
"beta", &betai, &b_beta);
350 tABinit->SetBranchAddress(
"width", &widthi, &b_width);
351 tABinit->SetBranchAddress(
"chi2", &chi2i, &b_chi2);
352 tABinit->SetBranchAddress(
"flag", &flagi, &b_flag);
355 TFile *fABout =
new TFile(namefile.c_str(),
"RECREATE");
356 tABout=
new TTree(
"ABCol0",
"ABCol0");
371 tABout->Branch(
"iphi", &iphi,
"iphi/I" );
372 tABout->Branch(
"ieta", &ieta,
"ieta/I" );
373 tABout->Branch(
"side", &side,
"side/I" );
374 tABout->Branch(
"dccID", &dccID,
"dccID/I" );
375 tABout->Branch(
"towerID", &towerID,
"towerID/I" );
376 tABout->Branch(
"channelID", &channelID,
"channelID/I" );
377 tABout->Branch(
"alpha", &alpha,
"alpha/D" );
378 tABout->Branch(
"beta", &beta,
"beta/D" );
379 tABout->Branch(
"width", &width,
"width/D" );
380 tABout->Branch(
"chi2", &chi2,
"chi2/D" );
381 tABout->Branch(
"flag", &flag,
"flag/I" );
383 tABout->SetBranchAddress(
"ieta", &ieta );
384 tABout->SetBranchAddress(
"iphi", &iphi );
385 tABout->SetBranchAddress(
"side", &side );
386 tABout->SetBranchAddress(
"dccID", &dccID );
387 tABout->SetBranchAddress(
"towerID", &towerID );
388 tABout->SetBranchAddress(
"channelID", &channelID );
389 tABout->SetBranchAddress(
"alpha", &alpha );
390 tABout->SetBranchAddress(
"beta", &beta );
391 tABout->SetBranchAddress(
"width", &width );
392 tABout->SetBranchAddress(
"chi2", &chi2 );
393 tABout->SetBranchAddress(
"flag", &flag );
395 for(
int i=0;
i<nchsel;
i++) {
399 tABinit->GetEntry(
i);
405 channelID=channelIDi;
413 towerID=tower_init[
i];
414 channelID=ch_init[
i];
436 double tm_mean=0;
double tm_sig=0;
438 double tm=0.;
double sigtm=0.;
440 if(1. < tm_val[
k] && tm_val[
k] < 10.) {
443 sigtm+= tm_val[
k]*tm_val[
k];
446 if(npassok[i] <= 0) {
447 tm_mean=0.; tm_sig=0.;
449 for(
int k=0;
k<npass[
i]-1;
k++) {
450 if(1. < tm_val[
k] && tm_val[
k] < 10.) {
451 double ss= (sigtm/npassok[
i]-tm/npassok[
i]*tm/npassok[
i]);
454 tm_mean= tm/npassok[
i];
459 putwidthVal(i,tm_mean);
523 std::vector<double>
v;
525 v.push_back(alpha_val[n]);
526 v.push_back(beta_val[n]);
527 v.push_back(width_val[n]);
528 v.push_back(chi2_val[n]);
529 v.push_back(flag_val[n]);
536 std::vector<double>
v;
538 v.push_back(alpha_init[n]);
539 v.push_back(beta_init[n]);
540 v.push_back(width_init[n]);
541 v.push_back(chi2_init[n]);
542 v.push_back(flag_init[n]);
551 sprintf(
filename,
"runABW%d.pedestal",gRunNumber);
553 if(fd ==
NULL) printf(
"Error while opening file : %s\n",
filename);
555 for(
int i=0;
i<nchsel;
i++) {
557 nev= (int) npassok[
i];
558 double trise= alpha_val[
i]*beta_val[
i];
559 fprintf( fd,
"%d %d 1 %ld %ld %f %f %f %f\n",
560 index[
i],nev,timestart,timestop,alpha_val[i],beta_val[i],trise,width_val[i]);
564 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 *)
double fitpj(double **, double *, double **, double noise_val, int debug)
void putphiInit(int, int)