64 |
memset(mip, 0, 2*22*96*sizeof(Float_t)); |
memset(mip, 0, 2*22*96*sizeof(Float_t)); |
65 |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
66 |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
67 |
|
memset(obadmask, 0, 2*22*96*sizeof(Int_t)); |
68 |
|
memset(obadpulsemask, 0, 2*22*6*sizeof(Int_t)); |
69 |
|
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
70 |
|
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
71 |
calopar1 = true; |
calopar1 = true; |
72 |
calopar2 = true; |
calopar2 = true; |
73 |
calopar3 = true; |
calopar3 = true; |
82 |
|
|
83 |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
84 |
crosst = ct; |
crosst = ct; |
85 |
}; |
} |
86 |
|
|
87 |
|
void CaloLevel0::SetCrossTalkType(Bool_t ct){ |
88 |
|
ctground = ct; |
89 |
|
} |
90 |
|
|
91 |
void CaloLevel0::SetVerbose(Bool_t ct){ |
void CaloLevel0::SetVerbose(Bool_t ct){ |
92 |
verbose = ct; |
verbose = ct; |
93 |
}; |
} |
94 |
|
|
95 |
|
/** |
96 |
|
* Initialize CaloLevel0 object |
97 |
|
**/ |
98 |
|
void CaloLevel0::ProcessingInit(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
99 |
|
if ( !dbc->IsConnected() ) throw -116; |
100 |
|
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
101 |
|
} |
102 |
|
|
103 |
/** |
/** |
104 |
* Initialize CaloLevel0 object |
* Initialize CaloLevel0 object |
110 |
const TString psw = glt->CGetPsw(); |
const TString psw = glt->CGetPsw(); |
111 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
112 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
113 |
|
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
114 |
|
dbc->Close(); |
115 |
|
delete dbc; |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
void CaloLevel0::InitDo(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
120 |
|
stringstream myquery; |
121 |
|
myquery.str(""); |
122 |
|
myquery << "SET time_zone='+0:00'"; |
123 |
|
dbc->Query(myquery.str().c_str()); |
124 |
// |
// |
125 |
debug = isdeb; |
debug = isdeb; |
126 |
verbose = isverb; |
verbose = isverb; |
197 |
// |
// |
198 |
delete glcalo; |
delete glcalo; |
199 |
delete glroot; |
delete glroot; |
|
dbc->Close(); |
|
|
delete dbc; |
|
200 |
// |
// |
201 |
return; |
return; |
202 |
// |
// |
213 |
return(sgnl); |
return(sgnl); |
214 |
} |
} |
215 |
|
|
216 |
|
Int_t CaloLevel0::ChkParam(TSQLServer *dbc, UInt_t runheader, Bool_t mechal){ |
217 |
|
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
218 |
|
return(sig); |
219 |
|
} |
220 |
|
|
221 |
Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ |
Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ |
222 |
const TString host = glt->CGetHost(); |
const TString host = glt->CGetHost(); |
223 |
const TString user = glt->CGetUser(); |
const TString user = glt->CGetUser(); |
224 |
const TString psw = glt->CGetPsw(); |
const TString psw = glt->CGetPsw(); |
225 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
226 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
227 |
|
stringstream myquery; |
228 |
|
myquery.str(""); |
229 |
|
myquery << "SET time_zone='+0:00'"; |
230 |
|
dbc->Query(myquery.str().c_str()); |
231 |
|
// |
232 |
|
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
233 |
|
dbc->Close(); |
234 |
|
delete dbc; |
235 |
|
return(sig); |
236 |
|
} |
237 |
|
|
238 |
|
Int_t CaloLevel0::ChkParamDo(TSQLServer *dbc, UInt_t runheader, Bool_t mechal){ |
239 |
// |
// |
240 |
stringstream calfile; |
stringstream calfile; |
241 |
stringstream bmfile; |
stringstream bmfile; |
247 |
// |
// |
248 |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
249 |
// |
// |
|
// |
|
|
// |
|
250 |
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
251 |
// |
// |
252 |
calopar1 = false; |
calopar1 = false; |
284 |
}; |
}; |
285 |
// |
// |
286 |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
287 |
|
// |
288 |
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
289 |
calopar2 = false; |
calopar2 = false; |
290 |
// |
// |
332 |
fread(&tmp,sizeof(clevel1->xalig),1,f); |
fread(&tmp,sizeof(clevel1->xalig),1,f); |
333 |
fread(&tmp,sizeof(clevel1->yalig),1,f); |
fread(&tmp,sizeof(clevel1->yalig),1,f); |
334 |
fread(&tmp,sizeof(clevel1->zalig),1,f); |
fread(&tmp,sizeof(clevel1->zalig),1,f); |
335 |
|
// clevel1->zalig = -265.82; |
336 |
// |
// |
337 |
}; |
}; |
338 |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
392 |
}; |
}; |
393 |
// |
// |
394 |
delete glparam; |
delete glparam; |
395 |
|
// |
396 |
|
return(0); |
397 |
|
} |
398 |
|
|
399 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(TSQLServer *dbc, UInt_t runheader){ |
400 |
|
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader); |
401 |
|
return(sig); |
402 |
|
} |
403 |
|
|
404 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader){ |
405 |
|
const TString host = glt->CGetHost(); |
406 |
|
const TString user = glt->CGetUser(); |
407 |
|
const TString psw = glt->CGetPsw(); |
408 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
409 |
|
if ( !dbc->IsConnected() ) throw -116; |
410 |
|
stringstream myquery; |
411 |
|
myquery.str(""); |
412 |
|
myquery << "SET time_zone='+0:00'"; |
413 |
|
dbc->Query(myquery.str().c_str()); |
414 |
|
// |
415 |
|
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader); |
416 |
dbc->Close(); |
dbc->Close(); |
417 |
delete dbc; |
delete dbc; |
418 |
// |
// |
419 |
|
return(sig); |
420 |
|
// |
421 |
|
} |
422 |
|
|
423 |
|
Int_t CaloLevel0::CalcCrossTalkCorrDo(TSQLServer *dbc, UInt_t runheader){ |
424 |
|
// |
425 |
|
if ( ctground ) return(0); |
426 |
|
// |
427 |
|
stringstream bmfile; |
428 |
|
Int_t error = 0; |
429 |
|
ifstream badfile; |
430 |
|
GL_PARAM *glparam = new GL_PARAM(); |
431 |
|
// |
432 |
|
// determine where I can find file with offline bad pulser mask |
433 |
|
// |
434 |
|
error = 0; |
435 |
|
error = glparam->Query_GL_PARAM(runheader,105,dbc); |
436 |
|
if ( error < 0 ) return(error); |
437 |
|
// |
438 |
|
bmfile.str(""); |
439 |
|
bmfile << glparam->PATH.Data() << "/"; |
440 |
|
bmfile << glparam->NAME.Data(); |
441 |
|
// |
442 |
|
if ( verbose ) printf("\n Using bad pulser offline mask file: \n %s \n\n",bmfile.str().c_str()); |
443 |
|
badfile.open(bmfile.str().c_str()); |
444 |
|
if ( !badfile ){ |
445 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no bad pulser offline mask file!\n"); |
446 |
|
return(-115); |
447 |
|
}; |
448 |
|
// |
449 |
|
Bool_t isdone = false; |
450 |
|
Int_t bad = 0; |
451 |
|
Int_t view = 1; |
452 |
|
Int_t pre = 0; |
453 |
|
Int_t plane = 21; |
454 |
|
while ( !isdone ) { |
455 |
|
badfile >> bad; |
456 |
|
obadpulsemask[view][plane][pre] = bad; |
457 |
|
if ( debug && bad ) printf(" SETTING view %i plane %i pre %i BAD = %i \n",view,plane,pre,bad); |
458 |
|
pre++; |
459 |
|
if ( pre > 5 ){ |
460 |
|
pre = 0; |
461 |
|
plane--; |
462 |
|
if ( plane < 0 ){ |
463 |
|
plane = 21; |
464 |
|
view--; |
465 |
|
}; |
466 |
|
if ( view < 0 ) isdone = true; |
467 |
|
}; |
468 |
|
}; |
469 |
|
// |
470 |
|
delete glparam; |
471 |
|
badfile.close(); |
472 |
|
// |
473 |
|
// Let's start with cross-talk correction calculation |
474 |
|
// |
475 |
|
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
476 |
|
Float_t adcp[2][22][96]; |
477 |
|
Float_t adcpcal[2][22][96]; |
478 |
|
memset(adcp , 0, 2*22*96*sizeof(Float_t)); |
479 |
|
memset(adcpcal , 0, 2*22*96*sizeof(Float_t)); |
480 |
|
// |
481 |
|
UInt_t pampli = 0; |
482 |
|
for (Int_t s=0; s<4; s++){ |
483 |
|
// |
484 |
|
// Save into matrix adcp the values of the highest pulse calibration (pulse amplitude = 2) |
485 |
|
// |
486 |
|
pampli = 2; |
487 |
|
error = 0; |
488 |
|
error = glp->Query_GL_CALOPULSE_CALIB(runheader,s,pampli,dbc); |
489 |
|
if ( error < 0 ){ |
490 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
491 |
|
return(error); |
492 |
|
}; |
493 |
|
// |
494 |
|
UInt_t idcalib = glp->ID_ROOT_L0; |
495 |
|
UInt_t fromtime = glp->FROM_TIME; |
496 |
|
UInt_t calibno = glp->EV_ROOT; |
497 |
|
// |
498 |
|
// determine path and name and entry of the calibration file |
499 |
|
// |
500 |
|
GL_ROOT *glroot = new GL_ROOT(); |
501 |
|
if ( verbose ) printf("\n"); |
502 |
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
503 |
|
// |
504 |
|
error = 0; |
505 |
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
506 |
|
if ( error < 0 ){ |
507 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
508 |
|
return(error); |
509 |
|
}; |
510 |
|
// |
511 |
|
stringstream name; |
512 |
|
name.str(""); |
513 |
|
name << glroot->PATH.Data() << "/"; |
514 |
|
name << glroot->NAME.Data(); |
515 |
|
// |
516 |
|
TString fcalname = (TString)name.str().c_str(); |
517 |
|
ifstream myfile; |
518 |
|
myfile.open(fcalname.Data()); |
519 |
|
if ( !myfile ){ |
520 |
|
return(-107); |
521 |
|
}; |
522 |
|
myfile.close(); |
523 |
|
// |
524 |
|
TFile *File = new TFile(fcalname.Data()); |
525 |
|
if ( !File ) return(-108); |
526 |
|
TTree *tr = (TTree*)File->Get("CalibCalPulse2"); |
527 |
|
if ( !tr ) return(-119); |
528 |
|
// |
529 |
|
TBranch *calo = tr->GetBranch("CalibCalPulse2"); |
530 |
|
// |
531 |
|
pamela::CalibCalPulse2Event *ce = 0; |
532 |
|
tr->SetBranchAddress("CalibCalPulse2", &ce); |
533 |
|
// |
534 |
|
Long64_t ncalibs = calo->GetEntries(); |
535 |
|
// |
536 |
|
if ( !ncalibs ) return(-110); |
537 |
|
// |
538 |
|
calo->GetEntry(calibno); |
539 |
|
if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); |
540 |
|
// |
541 |
|
// retrieve calibration table |
542 |
|
// |
543 |
|
if ( ce->pstwerr[s] && ce->pperror[s] == 0 && ce->unpackError == 0 ){ |
544 |
|
for ( Int_t d=0 ; d<11 ;d++ ){ |
545 |
|
for ( Int_t j=0; j<96 ;j++){ |
546 |
|
if ( s == 2 ){ |
547 |
|
adcp[0][2*d+1][j] = ce->calpuls[3][d][j]; |
548 |
|
}; |
549 |
|
if ( s == 3 ){ |
550 |
|
adcp[0][2*d][j] = ce->calpuls[1][d][j]; |
551 |
|
}; |
552 |
|
if ( s == 0 ){ |
553 |
|
adcp[1][2*d][j] = ce->calpuls[0][d][j]; |
554 |
|
}; |
555 |
|
if ( s == 1 ){ |
556 |
|
adcp[1][2*d+1][j] = ce->calpuls[2][d][j]; |
557 |
|
}; |
558 |
|
}; |
559 |
|
}; |
560 |
|
} else { |
561 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
562 |
|
return(-111); |
563 |
|
}; |
564 |
|
// |
565 |
|
File->Close(); |
566 |
|
delete glroot; |
567 |
|
// |
568 |
|
// Save into matrix adcpcal the calibrated values of the pulse calibration (subtraction of pulse amplitude = 0 relative to the pulse2 calibration used) |
569 |
|
// |
570 |
|
pampli = 0; |
571 |
|
error = 0; |
572 |
|
error = glp->Query_GL_CALOPULSE_CALIB(fromtime,s,pampli,dbc); |
573 |
|
if ( error < 0 ){ |
574 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
575 |
|
return(error); |
576 |
|
}; |
577 |
|
// |
578 |
|
idcalib = glp->ID_ROOT_L0; |
579 |
|
calibno = glp->EV_ROOT; |
580 |
|
// |
581 |
|
// determine path and name and entry of the calibration file |
582 |
|
// |
583 |
|
glroot = new GL_ROOT(); |
584 |
|
if ( verbose ) printf("\n"); |
585 |
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
586 |
|
// |
587 |
|
error = 0; |
588 |
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
589 |
|
if ( error < 0 ){ |
590 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
591 |
|
return(error); |
592 |
|
}; |
593 |
|
// |
594 |
|
name.str(""); |
595 |
|
name << glroot->PATH.Data() << "/"; |
596 |
|
name << glroot->NAME.Data(); |
597 |
|
// |
598 |
|
fcalname = (TString)name.str().c_str(); |
599 |
|
myfile.open(fcalname.Data()); |
600 |
|
if ( !myfile ){ |
601 |
|
return(-107); |
602 |
|
}; |
603 |
|
myfile.close(); |
604 |
|
// |
605 |
|
TFile *File1 = new TFile(fcalname.Data()); |
606 |
|
if ( !File1 ) return(-108); |
607 |
|
TTree *tr1 = (TTree*)File1->Get("CalibCalPulse1"); |
608 |
|
if ( !tr1 ) return(-120); |
609 |
|
// |
610 |
|
TBranch *calo1 = tr1->GetBranch("CalibCalPulse1"); |
611 |
|
// |
612 |
|
pamela::CalibCalPulse1Event *ce1 = 0; |
613 |
|
tr1->SetBranchAddress("CalibCalPulse1", &ce1); |
614 |
|
// |
615 |
|
ncalibs = calo1->GetEntries(); |
616 |
|
// |
617 |
|
if ( !ncalibs ) return(-110); |
618 |
|
// |
619 |
|
calo1->GetEntry(calibno); |
620 |
|
if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); |
621 |
|
// |
622 |
|
// retrieve calibration table |
623 |
|
// |
624 |
|
if ( ce1->pstwerr[s] && ce1->pperror[s] == 0 && ce1->unpackError == 0 ){ |
625 |
|
for ( Int_t d=0 ; d<11 ;d++ ){ |
626 |
|
for ( Int_t j=0; j<96 ;j++){ |
627 |
|
if ( s == 2 ){ |
628 |
|
adcpcal[0][2*d+1][j] = adcp[0][2*d+1][j] - ce1->calpuls[3][d][j]; |
629 |
|
}; |
630 |
|
if ( s == 3 ){ |
631 |
|
adcpcal[0][2*d][j] = adcp[0][2*d][j] - ce1->calpuls[1][d][j]; |
632 |
|
}; |
633 |
|
if ( s == 0 ){ |
634 |
|
adcpcal[1][2*d][j] = adcp[1][2*d][j] - ce1->calpuls[0][d][j]; |
635 |
|
}; |
636 |
|
if ( s == 1 ){ |
637 |
|
adcpcal[1][2*d+1][j] = adcp[1][2*d+1][j] - ce1->calpuls[2][d][j]; |
638 |
|
}; |
639 |
|
}; |
640 |
|
}; |
641 |
|
} else { |
642 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
643 |
|
return(-111); |
644 |
|
}; |
645 |
|
// |
646 |
|
File1->Close(); |
647 |
|
// |
648 |
|
delete glroot; |
649 |
|
// |
650 |
|
};// loop on the four sections |
651 |
|
// |
652 |
|
// |
653 |
|
delete glp; |
654 |
|
// |
655 |
|
// Ok, now we can try to calculate the cross-talk correction for each pre-amplifier |
656 |
|
// |
657 |
|
for ( Int_t v=0; v<2; v++){ |
658 |
|
if ( debug ) printf(" \n\n NEW VIEW \n"); |
659 |
|
for ( Int_t p=0; p<22; p++){ |
660 |
|
for ( Int_t npre=0; npre<6; npre++){ |
661 |
|
ctprecor[v][p][npre] = 1000.; |
662 |
|
ctneigcor[v][p][npre] = 1000.; |
663 |
|
Int_t str0=npre*16; |
664 |
|
Int_t str16= -1 + (1+npre)*16; |
665 |
|
// |
666 |
|
UInt_t neigc = 0; |
667 |
|
UInt_t farc = 0; |
668 |
|
UInt_t pulsc = 0; |
669 |
|
Float_t sigpulsed = 0.; |
670 |
|
Float_t neigbase = 0.; |
671 |
|
Float_t farbase = 0.; |
672 |
|
// |
673 |
|
// Loop over the strip of the pre and sum all signal far away from pulsed strip, signal in the neighbour(s) strip(s) and save the pulsed signal |
674 |
|
// moreover count the number of strips in each case |
675 |
|
// |
676 |
|
for (Int_t s=str0; s<=str16; s++){ |
677 |
|
if ( adcpcal[v][p][s] > 10000.){ |
678 |
|
sigpulsed = adcpcal[v][p][s]; |
679 |
|
pulsc++; |
680 |
|
if ( s > str0 ){ |
681 |
|
neigbase += adcpcal[v][p][s-1]; |
682 |
|
neigc++; |
683 |
|
farbase -= adcpcal[v][p][s-1]; |
684 |
|
farc--; |
685 |
|
}; |
686 |
|
if ( s < str16 ){ |
687 |
|
neigbase += adcpcal[v][p][s+1]; |
688 |
|
neigc++; |
689 |
|
farbase -= adcpcal[v][p][s+1]; |
690 |
|
farc--; |
691 |
|
}; |
692 |
|
} else { |
693 |
|
farc++; |
694 |
|
farbase += adcpcal[v][p][s]; |
695 |
|
}; |
696 |
|
}; |
697 |
|
// |
698 |
|
// Now calculate the corrections |
699 |
|
// |
700 |
|
Float_t avefarbase = 0.; |
701 |
|
if ( farc ) avefarbase = farbase/(Float_t)farc; |
702 |
|
Float_t aveneigbase = 0.; |
703 |
|
if ( neigc ) aveneigbase = neigbase/(Float_t)neigc; |
704 |
|
// |
705 |
|
if ( pulsc == 1 && farc && neigc ){ |
706 |
|
ctprecor[v][p][npre] = -avefarbase/(sigpulsed+fabs(avefarbase)); |
707 |
|
ctneigcor[v][p][npre] = fabs(aveneigbase-avefarbase)/(sigpulsed+fabs(avefarbase)); |
708 |
|
if ( debug ) printf(" Cross-talk correction View %i Plane %i Pre %i : pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); |
709 |
|
} else { |
710 |
|
// |
711 |
|
// did not find the pulsed strip or more than one pulsed strip found! |
712 |
|
// |
713 |
|
if ( debug ) printf(" Problems finding the cross-talk corrections: \n View %i Plane %i Pre %i number of pulsed strip %i \n Average faraway baseline %f number of strips %i Average neighbour baseline %f number of neighbour strips %i \n",v,p,npre,pulsc,avefarbase,farc,aveneigbase,neigc); |
714 |
|
// |
715 |
|
}; |
716 |
|
}; |
717 |
|
if ( debug ) printf(" \n ==================== \n"); |
718 |
|
}; |
719 |
|
}; |
720 |
|
// |
721 |
|
// Check the calculated corrections |
722 |
|
// |
723 |
|
Int_t opre=0; |
724 |
|
Int_t ppre=0; |
725 |
|
Bool_t found = false; |
726 |
|
for ( Int_t v=0; v<2; v++){ |
727 |
|
for ( Int_t p=0; p<22; p++){ |
728 |
|
for ( Int_t npre=0; npre<6; npre++){ |
729 |
|
if ( ctprecor[v][p][npre] == 1000. || ctneigcor[v][p][npre] == 1000. || obadpulsemask[v][p][npre] != 0 ){ |
730 |
|
if ( debug ) printf(" Cross-talk correction CHANGED for view %i Plane %i Pre %i\n BEFORE: pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); |
731 |
|
if ( npre%2 ){ |
732 |
|
opre = npre-1; |
733 |
|
} else { |
734 |
|
opre = npre+1; |
735 |
|
}; |
736 |
|
if ( ctprecor[v][p][opre] == 1000. || ctneigcor[v][p][opre] == 1000. || obadpulsemask[v][p][opre] != 0 ){ |
737 |
|
ppre=0; |
738 |
|
found = false; |
739 |
|
while ( ppre < 6 ){ |
740 |
|
if ( ctprecor[v][p][ppre] != 1000. && ctneigcor[v][p][ppre] != 1000. && !obadpulsemask[v][p][ppre] ){ |
741 |
|
found = true; |
742 |
|
ctprecor[v][p][npre] = ctprecor[v][p][ppre]; |
743 |
|
ctneigcor[v][p][npre] = ctneigcor[v][p][ppre]; |
744 |
|
break; |
745 |
|
}; |
746 |
|
ppre++; |
747 |
|
}; |
748 |
|
if ( !found ){ |
749 |
|
if ( verbose ) printf(" WARNING: cannot find a good cross-talk correction for view %i plane %i pre %i \n Setting to default values 0.002 0.002\n",v,p,npre); |
750 |
|
ctprecor[v][p][npre] = 0.002; |
751 |
|
ctneigcor[v][p][npre] = 0.002; |
752 |
|
}; |
753 |
|
} else { |
754 |
|
ctprecor[v][p][npre] = ctprecor[v][p][opre]; |
755 |
|
ctneigcor[v][p][npre] = ctneigcor[v][p][opre]; |
756 |
|
}; |
757 |
|
if ( debug ) printf(" AFTER: pre-correction: %f neighbour strips correction %f \n",ctprecor[v][p][npre],ctneigcor[v][p][npre]); |
758 |
|
}; |
759 |
|
}; |
760 |
|
}; |
761 |
|
}; |
762 |
|
// |
763 |
return(0); |
return(0); |
764 |
} |
} |
765 |
|
|
766 |
|
void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre){ |
767 |
|
Int_t n = 0; |
768 |
|
Float_t q = 0; |
769 |
|
this->FindBaseCompress(l,m,pre,n,q); |
770 |
|
} |
771 |
|
|
772 |
|
void CaloLevel0::FindBaseCompress(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ |
773 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
774 |
|
dexy[l][m][e] = dexyc[l][m][e]; |
775 |
|
}; |
776 |
|
this->FindBaseRaw(l,m,pre,nst,qp); |
777 |
|
} |
778 |
|
|
779 |
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ |
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre){ |
780 |
Float_t minstrip = 100000.; |
Int_t n = 0; |
781 |
Float_t rms = 0.; |
Float_t q = 0; |
782 |
|
this->FindBaseRaw(l,m,pre,n,q); |
783 |
|
} |
784 |
|
|
785 |
|
void CaloLevel0::FindBaseRaw(Int_t l, Int_t m, Int_t pre, Int_t &nst, Float_t &qp){ |
786 |
|
// |
787 |
|
Float_t minstrip = 100000.; |
788 |
|
Float_t rms = 0.; |
789 |
|
Int_t process = 0; |
790 |
|
Int_t onlmask[16]; |
791 |
|
memset(onlmask, 0, 16*sizeof(Int_t)); |
792 |
|
// |
793 |
|
while ( process < 2 ){ |
794 |
|
// |
795 |
|
minstrip = 100000.; |
796 |
|
rms = 0.; |
797 |
base[l][m][pre] = 0.; |
base[l][m][pre] = 0.; |
798 |
|
qp = 0.; |
799 |
|
// |
800 |
|
Int_t spos = -1; |
801 |
|
Int_t ee = 0; |
802 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
803 |
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0.) { |
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0. && onlmask[ee] == 0 ) { |
804 |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
805 |
rms = calthr[l][m][pre]; |
rms = calthr[l][m][pre]; |
806 |
}; |
spos = ee; |
807 |
|
}; |
808 |
|
ee++; |
809 |
|
qp += (dexy[l][m][e]-calped[l][m][e]-sbase[l][m][e]); |
810 |
|
}; |
811 |
|
// |
812 |
|
if ( debug && l==0 ){ |
813 |
|
printf("\n BASELINE CALCULATION for view %i pl %i pre %i: \n => minstrip %f rms %f \n => qp = %f \n",l,m,pre,minstrip,rms,qp); |
814 |
}; |
}; |
815 |
if ( minstrip != 100000. ) { |
if ( minstrip != 100000. ) { |
816 |
Float_t strip6s = 0.; |
Float_t strip6s = 0.; |
817 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
818 |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
819 |
strip6s += 1.; |
strip6s += 1.; |
820 |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
|
}; |
|
|
// |
|
|
// compression |
|
|
// |
|
|
if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
|
|
dexyc[l][m][e] = 0.; |
|
|
} else { |
|
|
dexyc[l][m][e] = dexy[l][m][e]; |
|
|
}; |
|
821 |
}; |
}; |
822 |
if ( strip6s >= 9. ){ |
// |
823 |
Double_t arro = base[l][m][pre]/strip6s; |
// compression |
824 |
Float_t deci = 1000.*((float)arro - float(int(arro))); |
// |
825 |
if ( deci < 500. ) { |
// if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
826 |
arro = double(int(arro)); |
// dexyc[l][m][e] = 0.; |
827 |
} else { |
// } else { |
828 |
arro = 1. + double(int(arro)); |
dexyc[l][m][e] = dexy[l][m][e]; |
829 |
}; |
// }; |
830 |
base[l][m][pre] = arro; |
}; |
831 |
|
// |
832 |
|
if ( strip6s == 1. && process < 1 ){ |
833 |
|
onlmask[spos] = 1; |
834 |
|
process++; |
835 |
|
continue; |
836 |
|
}; |
837 |
|
process += 2; |
838 |
|
nst = (Int_t)strip6s; |
839 |
|
// |
840 |
|
if ( debug && l==1 ){ |
841 |
|
printf(" strip6s %f \n",strip6s); |
842 |
|
}; |
843 |
|
// if ( strip6s >= 9. ){ |
844 |
|
if ( (strip6s >= 2. && process == 2) || (strip6s >= 9. && process > 2) ){ |
845 |
|
Double_t arro = base[l][m][pre]/strip6s; |
846 |
|
Float_t deci = 1000.*((float)arro - float(int(arro))); |
847 |
|
if ( deci < 500. ) { |
848 |
|
arro = double(int(arro)); |
849 |
} else { |
} else { |
850 |
base[l][m][pre] = 31000.; |
arro = 1. + double(int(arro)); |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
|
|
dexyc[l][m][e] = dexy[l][m][e]; |
|
|
}; |
|
851 |
}; |
}; |
852 |
} else { |
base[l][m][pre] = arro; |
853 |
|
// |
854 |
|
// if too few strips were used to determine the baseline check if it is comparable with the previous event, if not mark it as bad |
855 |
|
// |
856 |
|
if ( debug && l==1 ) printf(" Calculated baseline: base %f sbase*1.02 %f \n",base[l][m][pre],1.02*sbase[l][m][pre]); |
857 |
|
// |
858 |
|
if ( strip6s < 4 && base[l][m][pre] > 1.02*sbase[l][m][pre] && sbase[l][m][pre] > 0. ){ |
859 |
|
if ( debug ) printf(" Suspicious calculated baseline: base %f sbase*1.02 %f strip6s %i \n",base[l][m][pre],1.02*sbase[l][m][pre],(Int_t)strip6s); |
860 |
|
base[l][m][pre] = 31000.; |
861 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
862 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
863 |
|
}; |
864 |
|
}; |
865 |
|
} else { |
866 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
867 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
868 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
869 |
|
}; |
870 |
|
}; |
871 |
|
} else { |
872 |
|
process += 2; |
873 |
|
base[l][m][pre] = 31000.; |
874 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
875 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
876 |
|
}; |
877 |
}; |
}; |
878 |
|
}; |
879 |
} |
} |
880 |
|
|
881 |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
Int_t CaloLevel0::Calibrate(Int_t ei){ |
886 |
// |
// |
887 |
// if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. |
// if it was not a selftrigger event, could it ever been a selftrigger event? if so trigty = 3. |
888 |
// |
// |
889 |
|
clevel2->nsatstrip = 0.; |
890 |
Int_t val = 0; |
Int_t val = 0; |
891 |
Int_t del = 1100; |
Int_t del = 1100; |
892 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
933 |
Float_t ener; |
Float_t ener; |
934 |
Int_t doneb = 0; |
Int_t doneb = 0; |
935 |
Int_t donec = 0; |
Int_t donec = 0; |
936 |
Int_t ck = 0; |
Int_t ck[6] = {0,0,0,0,0,0}; |
937 |
Int_t ipre = 0; |
Int_t ipre = 0; |
938 |
Int_t ip[3] = {0}; |
// Int_t ip[3] = {0}; |
939 |
|
Int_t ip[3] = {0,0,0}; |
940 |
Float_t base0, base1, base2; |
Float_t base0, base1, base2; |
941 |
base0 = 0.; |
base0 = 0.; |
942 |
base1 = 0.; |
base1 = 0.; |
1012 |
// |
// |
1013 |
pre = -1; |
pre = -1; |
1014 |
cbase0 = 0.; |
cbase0 = 0.; |
1015 |
|
Int_t nstt[2]; |
1016 |
|
Float_t rqp[2]; |
1017 |
for (Int_t i = 0; i < 3; i++){ |
for (Int_t i = 0; i < 3; i++){ |
1018 |
|
// nstt[0] = 0; // BUG |
1019 |
|
// nstt[1] = 0; // BUG |
1020 |
|
nstt[0] = 1000; |
1021 |
|
nstt[1] = 1000; |
1022 |
|
rqp[0] = 0.; |
1023 |
|
rqp[1] = 0.; |
1024 |
for (Int_t j = 0; j < 2; j++){ |
for (Int_t j = 0; j < 2; j++){ |
1025 |
pre = j + i*2; |
pre = j + i*2; |
1026 |
// |
// |
1027 |
// baseline check and calculation |
// baseline check and calculation |
1028 |
// |
// |
1029 |
if ( !isRAW ) { |
if ( !isRAW ){ |
1030 |
base[l][m][pre] = de->base[l][m][pre] ; |
// |
1031 |
|
// if it is a compress event with fully transmitted pre try to calculate the baseline |
1032 |
|
// |
1033 |
|
if ( de->base[l][m][pre] != 0. && de->base[l][m][pre]<31000. ) { |
1034 |
|
base[l][m][pre] = de->base[l][m][pre] ; |
1035 |
|
} else { |
1036 |
|
FindBaseCompress(l,m,pre,nstt[j],rqp[j]); |
1037 |
|
}; |
1038 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
1039 |
} else { |
} else { |
1040 |
// |
// |
1041 |
// if it is a raw event and we haven't checked |
// if it is a raw event calculate the baseline. |
|
// yet, calculate the baseline. |
|
1042 |
// |
// |
1043 |
FindBaseRaw(l,m,pre); |
FindBaseRaw(l,m,pre,nstt[j],rqp[j]); |
1044 |
cbase0 += base[l][m][pre]; |
cbase0 += base[l][m][pre]; |
1045 |
}; |
}; |
1046 |
}; |
}; |
1047 |
|
// |
1048 |
|
// if we are able to calculate the baseline with more than 3 strips on one pre and not in the other one choose the pre with more calculated strips |
1049 |
|
// |
1050 |
|
if ( nstt[0] < 4 && nstt[1] >= 4 && nstt[0] != 1000 && nstt[1] != 1000 ) base[l][m][pre-1] = 31000.; |
1051 |
|
if ( nstt[0] >= 4 && nstt[1] < 4 && nstt[0] != 1000 && nstt[1] != 1000 ) base[l][m][pre] = 31000.; |
1052 |
|
// if ( nstt[0] < 4 && nstt[1] >= 4 ) base[l][m][pre-1] = 31000.; // BUG |
1053 |
|
// if ( nstt[0] >= 4 && nstt[1] < 4 ) base[l][m][pre] = 31000.; // BUG |
1054 |
|
// // |
1055 |
|
// // if we are NOT able to calculate the baseline with more than 3 strips on both pres take the baseline (if any) of the one which has less energy |
1056 |
|
// // |
1057 |
|
// if ( nstt[0] < 4 && nstt[1] < 4 ){ |
1058 |
|
// if ( rqp[0] >= rqp[1] ) base[l][m][pre-1] = 31000.; |
1059 |
|
// if ( rqp[0] < rqp[1] ) base[l][m][pre] = 31000.; |
1060 |
|
// }; |
1061 |
}; |
}; |
1062 |
// |
// |
1063 |
// run over strips |
// run over strips |
1068 |
ip[i] = 0; |
ip[i] = 0; |
1069 |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
1070 |
if (n%16 == 0) { |
if (n%16 == 0) { |
|
ck = 0; |
|
1071 |
done = 0; |
done = 0; |
1072 |
doneb = 0; |
doneb = 0; |
1073 |
donec = 0; |
donec = 0; |
1074 |
pre++; |
pre++; |
1075 |
|
ck[pre] = 0; |
1076 |
qpre[pre] = 0.; |
qpre[pre] = 0.; |
1077 |
}; |
}; |
1078 |
// |
// |
1082 |
// |
// |
1083 |
if ( !done ){ |
if ( !done ){ |
1084 |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
1085 |
ck = 1; |
ck[pre] = 1; |
1086 |
if (pre%2 == 0) { |
if (pre%2 == 0) { |
1087 |
ip[i] = pre + 1; |
ip[i] = pre + 1; |
1088 |
} else { |
} else { |
1090 |
}; |
}; |
1091 |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
1092 |
// |
// |
1093 |
ck = 2; |
ck[pre] = 2; |
1094 |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
1095 |
ck = 3; |
ck[pre] = 3; |
1096 |
}; |
}; |
1097 |
}; |
}; |
1098 |
done = 1; |
// done = 1; |
1099 |
}; |
}; |
1100 |
|
done = 1; |
1101 |
}; |
}; |
1102 |
// |
// |
1103 |
// CALIBRATION ALGORITHM |
// CALIBRATION ALGORITHM |
1104 |
// |
// |
1105 |
if ( !doneb ){ |
if ( !doneb ){ |
1106 |
if ( debug ) printf(" ck is %i \n",ck); |
if ( debug ) printf(" ck[pre] is %i \n",ck[pre]); |
1107 |
switch (ck) { |
switch (ck[pre]) { |
1108 |
case 0: |
case 0: |
1109 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
1110 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
1111 |
if ( debug ) printf(" base0 = base l m pre = %f base2 = calbase l m pre = %f \n",base[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = base l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,base[l][m][pre],calbase[l][m][pre]); |
1112 |
break; |
break; |
1113 |
case 1: |
case 1: |
1114 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
1115 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
1116 |
if ( debug ) printf(" base0 = base l m ip(i) = %f base2 = calbase l m ip(i) = %f \n",base[l][m][ip[i]],calbase[l][m][ip[i]]); |
if ( debug ) printf(" base0 = base l%i m%i ip(i)%i = %f base2 = calbase l m ip(i) = %f \n",l,m,ip[i],base[l][m][ip[i]],calbase[l][m][ip[i]]); |
1117 |
break; |
break; |
1118 |
case 2: |
case 2: |
1119 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
1120 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
1121 |
if ( debug ) printf(" base0 = sbase l m pre = %f base2 = calbase l m pre = %f \n",sbase[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = sbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,sbase[l][m][pre],calbase[l][m][pre]); |
1122 |
break; |
break; |
1123 |
case 3: |
case 3: |
1124 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
1125 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
1126 |
if ( debug ) printf(" base0 = calbase l m pre = %f base2 = calbase l m pre = %f \n",calbase[l][m][pre],calbase[l][m][pre]); |
if ( debug ) printf(" base0 = calbase l%i m%i pre%i = %f base2 = calbase l m pre = %f \n",l,m,pre,calbase[l][m][pre],calbase[l][m][pre]); |
1127 |
break; |
break; |
1128 |
}; |
}; |
1129 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
1151 |
}; |
}; |
1152 |
}; |
}; |
1153 |
if ( crosst ){ |
if ( crosst ){ |
1154 |
if (ck == 1){ |
if (ck[pre] == 1 || ck[pre-1] == 1){ |
1155 |
if (ip[i]%2 == 0) { |
if (ck[pre] == 1){ |
1156 |
ipre = ip[i] + 1; |
ipre = pre; |
1157 |
|
ip[i] = pre - 1; |
1158 |
} else { |
} else { |
1159 |
ipre = ip[i] - 1; |
ipre = pre - 1; |
1160 |
|
ip[i] = pre; |
1161 |
}; |
}; |
1162 |
|
// if (ip[i]%2 == 0) { |
1163 |
|
// ipre = ip[i] + 1; |
1164 |
|
// } else { |
1165 |
|
// ipre = ip[i] - 1; |
1166 |
|
// }; |
1167 |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
1168 |
clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * 0.00478; |
if ( !ctground ){ |
1169 |
|
clevel1->estrip[j][m][l] += qpre[ipre] * ctprecor[l][m][ipre] - qpre[ip[i]] * ctprecor[l][m][ip[i]]; |
1170 |
|
} else { |
1171 |
|
clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * 0.00478; |
1172 |
|
}; |
1173 |
}; |
}; |
1174 |
}; |
}; |
1175 |
if (ck == 2){ |
if (ck[pre] == 2 && ck[pre-1] == 2){ |
1176 |
for (Int_t j = i*32 ; j < (i+1)*32 ; j++){ |
for (Int_t j = i*32 ; j < (i+1)*32 ; j++){ |
1177 |
ipre = j/16 + 1; |
// ipre = j/16 + 1; |
1178 |
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
ipre = j/16 ; |
1179 |
|
if ( !ctground ){ |
1180 |
|
clevel1->estrip[j][m][l] += qpre[ipre] * ctprecor[l][m][ipre]; |
1181 |
|
} else { |
1182 |
|
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
1183 |
|
}; |
1184 |
}; |
}; |
1185 |
}; |
}; |
1186 |
}; |
}; |
1195 |
Int_t j4 = -4; |
Int_t j4 = -4; |
1196 |
Int_t jjj = -3; |
Int_t jjj = -3; |
1197 |
Int_t jj = -2; |
Int_t jj = -2; |
1198 |
for (Int_t j = 0 ; j < 100 ; j++){ |
Int_t jjpre = -1; |
1199 |
|
Int_t jjjpre = -1; |
1200 |
|
for (Int_t j = 0 ; j < 100 ; j++){ |
1201 |
jj++; |
jj++; |
1202 |
jjj++; |
jjj++; |
1203 |
j4++; |
j4++; |
1204 |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
1205 |
if ( crosst ){ |
if ( crosst ){ |
1206 |
if ( jj >= 0 && jj < 96 ){ |
if ( jj >= 0 && jj < 96 ){ |
1207 |
if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; |
if ( !ctground ){ |
1208 |
if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581; |
if ( jj%16 == 0 ) jjpre++; |
1209 |
|
if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
1210 |
|
if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
1211 |
|
} else { |
1212 |
|
if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; |
1213 |
|
if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581; |
1214 |
|
}; |
1215 |
}; |
}; |
1216 |
if ( jjj >= 0 && jjj < 96 ){ |
if ( jjj >= 0 && jjj < 96 ){ |
1217 |
if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * 0.01581; |
if ( !ctground ){ |
1218 |
if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * 0.01581; |
if ( jjj%16 == 0 ) jjjpre++; |
1219 |
|
if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
1220 |
|
if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
1221 |
|
} else { |
1222 |
|
if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * 0.01581; |
1223 |
|
if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * 0.01581; |
1224 |
|
}; |
1225 |
}; |
}; |
1226 |
}; |
}; |
1227 |
if ( j4 >= 0 && j4 < 96 ){ |
if ( j4 >= 0 && j4 < 96 ){ |
1231 |
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
1232 |
clevel1->estrip[j4][m][l] = 0.; |
clevel1->estrip[j4][m][l] = 0.; |
1233 |
}; |
}; |
1234 |
// |
// |
1235 |
// code and save the energy for each strip in svstrip |
// code and save the energy for each strip in svstrip |
1236 |
// |
// |
1237 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
1238 |
// |
// |
1239 |
|
Float_t savel1 = clevel1->estrip[j4][m][l]; |
1240 |
|
if ( dexyc[l][m][j4] == 32767. ){ |
1241 |
|
savel1 += 5000.; |
1242 |
|
clevel2->nsatstrip += 1.; |
1243 |
|
}; |
1244 |
|
// |
1245 |
tim = 100000.; |
tim = 100000.; |
1246 |
plo = m; |
plo = m; |
1247 |
fbi = 0; |
fbi = 0; |
1248 |
if ( clevel1->estrip[j4][m][l] > 0.99995 ){ |
if ( savel1 > 0.99995 ){ |
1249 |
tim = 10000.; |
tim = 10000.; |
1250 |
plo = m; |
plo = m; |
1251 |
fbi = 1; |
fbi = 1; |
1252 |
}; |
}; |
1253 |
if ( clevel1->estrip[j4][m][l] > 9.9995 ){ |
if ( savel1 > 9.9995 ){ |
1254 |
tim = 1000.; |
tim = 1000.; |
1255 |
plo = 22 + m; |
plo = 22 + m; |
1256 |
fbi = 1; |
fbi = 1; |
1257 |
}; |
}; |
1258 |
if ( clevel1->estrip[j4][m][l] > 99.995 ){ |
if ( savel1 > 99.995 ){ |
1259 |
tim = 100.; |
tim = 100.; |
1260 |
plo = 22 + m; |
plo = 22 + m; |
1261 |
fbi = 0; |
fbi = 0; |
1262 |
}; |
}; |
1263 |
if ( clevel1->estrip[j4][m][l] > 999.95 ){ |
if ( savel1 > 999.95 ){ |
1264 |
tim = 10.; |
tim = 10.; |
1265 |
plo = 44 + m; |
plo = 44 + m; |
1266 |
fbi = 0; |
fbi = 0; |
1267 |
}; |
}; |
1268 |
if ( clevel1->estrip[j4][m][l] > 9999.5 ){ |
if ( savel1 > 9999.5 ){ |
1269 |
tim = 1.; |
tim = 1.; |
1270 |
plo = 66 + m; |
plo = 66 + m; |
1271 |
fbi = 0; |
fbi = 0; |
1272 |
}; |
}; |
1273 |
// |
// |
1274 |
cle = (Int_t)lroundf(tim*clevel1->estrip[j4][m][l]); |
cle = (Int_t)lroundf(tim*savel1); |
1275 |
// |
// |
1276 |
if ( l == 0 ){ |
if ( l == 0 ){ |
1277 |
// |
// |
1392 |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
1393 |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
1394 |
ca->nstrip = (Int_t)clevel2->nstrip; |
ca->nstrip = (Int_t)clevel2->nstrip; |
1395 |
|
ca->nsatstrip = (Int_t)clevel2->nsatstrip; |
1396 |
ca->qtot = clevel2->qtot; |
ca->qtot = clevel2->qtot; |
1397 |
// ca->impx = clevel2->impx; |
// ca->impx = clevel2->impx; |
1398 |
// ca->impy = clevel2->impy; |
// ca->impy = clevel2->impy; |
1437 |
memset(dexyc, 0, 2*22*96*sizeof(Float_t)); |
memset(dexyc, 0, 2*22*96*sizeof(Float_t)); |
1438 |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
1439 |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
1440 |
|
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
1441 |
|
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
1442 |
// |
// |
1443 |
} |
} |
1444 |
|
|
1483 |
clevel2->wartrig = 0.; |
clevel2->wartrig = 0.; |
1484 |
clevel2->good = 0; |
clevel2->good = 0; |
1485 |
clevel2->nstrip = 0.; |
clevel2->nstrip = 0.; |
1486 |
|
clevel2->nsatstrip = 0.; |
1487 |
clevel2->qtot = 0.; |
clevel2->qtot = 0.; |
1488 |
// clevel2->impx = 0.; |
// clevel2->impx = 0.; |
1489 |
// clevel2->impy = 0.; |
// clevel2->impy = 0.; |
1563 |
const TString psw = glt->CGetPsw(); |
const TString psw = glt->CGetPsw(); |
1564 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
1565 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
1566 |
|
stringstream myquery; |
1567 |
|
myquery.str(""); |
1568 |
|
myquery << "SET time_zone='+0:00'"; |
1569 |
|
dbc->Query(myquery.str().c_str()); |
1570 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
1571 |
// |
// |
1572 |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |