| 18 |
// YODA headers |
// YODA headers |
| 19 |
// |
// |
| 20 |
#include <PamelaRun.h> |
#include <PamelaRun.h> |
|
#include <RegistryEvent.h> |
|
| 21 |
#include <physics/calorimeter/CalorimeterEvent.h> |
#include <physics/calorimeter/CalorimeterEvent.h> |
| 22 |
#include <CalibCalPedEvent.h> |
#include <CalibCalPedEvent.h> |
| 23 |
// |
// |
| 66 |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
| 67 |
calopar1 = true; |
calopar1 = true; |
| 68 |
calopar2 = true; |
calopar2 = true; |
| 69 |
ftcalopar1 = 0ULL; |
ftcalopar1 = 0; |
| 70 |
ttcalopar1 = 0ULL; |
ttcalopar1 = 0; |
| 71 |
ftcalopar2 = 0ULL; |
ftcalopar2 = 0; |
| 72 |
ttcalopar2 = 0ULL; |
ttcalopar2 = 0; |
| 73 |
} |
} |
| 74 |
|
|
| 75 |
/** |
/** |
| 76 |
* Initialize CaloProcessing object |
* Initialize CaloProcessing object |
| 77 |
**/ |
**/ |
| 78 |
void CaloProcessing::ProcessingInit(TSQLServer *dbc, ULong64_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
void CaloProcessing::ProcessingInit(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
| 79 |
// |
// |
| 80 |
debug = isdeb; |
debug = isdeb; |
| 81 |
verbose = isverb; |
verbose = isverb; |
| 93 |
sgnl = 0; |
sgnl = 0; |
| 94 |
// |
// |
| 95 |
for (Int_t s = 0; s < 4; s++){ |
for (Int_t s = 0; s < 4; s++){ |
| 96 |
idcalib[s] = 0ULL; |
idcalib[s] = 0; |
| 97 |
fromtime[s] = 0ULL; |
fromtime[s] = 0; |
| 98 |
totime[s] = 0ULL; |
totime[s] = 0; |
| 99 |
calibno[s] = 0; |
calibno[s] = 0; |
| 100 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 101 |
// |
// |
| 102 |
sgnl = glcalo->Query_GL_CALO_CALIB(hs,s,dbc); |
sgnl = glcalo->Query_GL_CALO_CALIB(hs,s,dbc); |
| 103 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
| 104 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 105 |
return; |
return; |
| 106 |
}; |
}; |
| 107 |
// |
// |
| 108 |
idcalib[s] = glcalo->ID_REG_CALIBCALPED; |
idcalib[s] = glcalo->ID_ROOT_L0; |
| 109 |
fromtime[s] = glcalo->FROM_TIME; |
fromtime[s] = glcalo->FROM_TIME; |
| 110 |
totime[s] = glcalo->TO_TIME; |
totime[s] = glcalo->TO_TIME; |
| 111 |
calibno[s] = glcalo->EV_REG_CALIBCALPED; |
calibno[s] = glcalo->EV_ROOT; |
| 112 |
// |
// |
| 113 |
if ( totime[s] == 0ULL){ |
if ( totime[s] == 0 ){ |
| 114 |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
| 115 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 116 |
sgnl = 100; |
sgnl = 100; |
| 123 |
if ( verbose ) printf("\n"); |
if ( verbose ) printf("\n"); |
| 124 |
for (Int_t s = 0; s < 4; s++){ |
for (Int_t s = 0; s < 4; s++){ |
| 125 |
if ( verbose ) printf(" ** SECTION %i **\n",s); |
if ( verbose ) printf(" ** SECTION %i **\n",s); |
| 126 |
if ( totime[s] > 0ULL ){ |
if ( totime[s] > 0 ){ |
| 127 |
// |
// |
| 128 |
sgnl = glroot->Query_GL_ROOT(idcalib[s],dbc); |
sgnl = glroot->Query_GL_ROOT(idcalib[s],dbc); |
| 129 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
| 130 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
| 131 |
return; |
return; |
| 132 |
}; |
}; |
| 133 |
// |
// |
| 134 |
stringstream name; |
stringstream name; |
| 135 |
name.str(""); |
name.str(""); |
| 136 |
name << glroot->PATH.Data() << "/"; |
name << glroot->PATH.Data() << "/"; |
| 137 |
name << glroot->NAME.Data(); |
name << glroot->NAME.Data(); |
| 138 |
// |
// |
| 139 |
fcalname[s] = (TString)name.str().c_str(); |
fcalname[s] = (TString)name.str().c_str(); |
| 140 |
if ( verbose ) printf(" - runheader at time %llu. From time %llu to time %llu \n use file %s \n calibration at entry %i \n\n",hs,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
if ( verbose ) printf(" - runheader at time %u. From time %u to time %u \n use file %s \n calibration at entry %i \n\n",hs,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
| 141 |
} else { |
} else { |
| 142 |
if ( verbose ) printf(" - runheader at time %llu. NO CALIBRATION INCLUDE THE RUNHEADER! ",hs); |
if ( verbose ) printf(" - runheader at time %u. NO CALIBRATION INCLUDE THE RUNHEADER! ",hs); |
| 143 |
}; |
}; |
| 144 |
sgnl = LoadCalib(s); |
sgnl = LoadCalib(s); |
| 145 |
if ( sgnl ) break; |
if ( sgnl ) break; |
| 152 |
// |
// |
| 153 |
} |
} |
| 154 |
|
|
| 155 |
Int_t CaloProcessing::ChkCalib(TSQLServer *dbc, ULong64_t atime){ |
Int_t CaloProcessing::ChkCalib(TSQLServer *dbc, UInt_t atime){ |
| 156 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
| 157 |
for ( Int_t s = 0; s < 4; s++){ |
for ( Int_t s = 0; s < 4; s++){ |
| 158 |
if ( atime > totime[s] ){ |
if ( atime > totime[s] ){ |
| 163 |
return(sgnl); |
return(sgnl); |
| 164 |
} |
} |
| 165 |
|
|
| 166 |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, ULong64_t runheader){ |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, UInt_t runheader){ |
| 167 |
stringstream calfile; |
stringstream calfile; |
| 168 |
stringstream aligfile; |
stringstream aligfile; |
| 169 |
Int_t error = 0; |
Int_t error = 0; |
| 178 |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
| 179 |
// |
// |
| 180 |
error = 0; |
error = 0; |
| 181 |
error = glparam->Query_GL_PARAM(runheader,"Calorimeter ADC to MIP",dbc); |
error = glparam->Query_GL_PARAM(runheader,101,dbc); |
| 182 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
| 183 |
// |
// |
| 184 |
calfile.str(""); |
calfile.str(""); |
| 211 |
// |
// |
| 212 |
// |
// |
| 213 |
error = 0; |
error = 0; |
| 214 |
error = glparam->Query_GL_PARAM(runheader,"Calorimeter alignement",dbc); |
error = glparam->Query_GL_PARAM(runheader,102,dbc); |
| 215 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
| 216 |
// |
// |
| 217 |
aligfile.str(""); |
aligfile.str(""); |
| 240 |
}; |
}; |
| 241 |
// |
// |
| 242 |
delete glparam; |
delete glparam; |
|
// delete f; |
|
| 243 |
// |
// |
| 244 |
return(0); |
return(0); |
| 245 |
} |
} |
| 777 |
return; |
return; |
| 778 |
} |
} |
| 779 |
|
|
| 780 |
Int_t CaloProcessing::Update(TSQLServer *dbc, ULong64_t atime, Int_t s){ |
Int_t CaloProcessing::Update(TSQLServer *dbc, UInt_t atime, Int_t s){ |
| 781 |
// |
// |
| 782 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
| 783 |
// |
// |
| 785 |
// |
// |
| 786 |
sgnl = 0; |
sgnl = 0; |
| 787 |
// |
// |
| 788 |
idcalib[s] = 0ULL; |
idcalib[s] = 0; |
| 789 |
fromtime[s] = 0ULL; |
fromtime[s] = 0; |
| 790 |
totime[s] = 0ULL; |
totime[s] = 0; |
| 791 |
calibno[s] = 0; |
calibno[s] = 0; |
| 792 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 793 |
// |
// |
| 797 |
return(sgnl); |
return(sgnl); |
| 798 |
}; |
}; |
| 799 |
// |
// |
| 800 |
idcalib[s] = glcalo->ID_REG_CALIBCALPED; |
idcalib[s] = glcalo->ID_ROOT_L0; |
| 801 |
fromtime[s] = glcalo->FROM_TIME; |
fromtime[s] = glcalo->FROM_TIME; |
| 802 |
totime[s] = glcalo->TO_TIME; |
totime[s] = glcalo->TO_TIME; |
| 803 |
calibno[s] = glcalo->EV_REG_CALIBCALPED; |
calibno[s] = glcalo->EV_ROOT; |
| 804 |
// |
// |
| 805 |
if ( totime[s] == 0ULL){ |
if ( totime[s] == 0 ){ |
| 806 |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
| 807 |
ClearCalibVals(s); |
ClearCalibVals(s); |
| 808 |
sgnl = 100; |
sgnl = 100; |
| 826 |
name << glroot->NAME.Data(); |
name << glroot->NAME.Data(); |
| 827 |
// |
// |
| 828 |
fcalname[s] = (TString)name.str().c_str(); |
fcalname[s] = (TString)name.str().c_str(); |
| 829 |
if ( verbose ) printf(" - event at time %llu. From time %llu to time %llu \n use file %s \n calibration at entry %i \n\n",atime,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
if ( verbose ) printf(" - event at time %u. From time %u to time %u \n use file %s \n calibration at entry %i \n\n",atime,fromtime[s],totime[s],fcalname[s].Data(),calibno[s]); |
| 830 |
// |
// |
| 831 |
sgnl = LoadCalib(s); |
sgnl = LoadCalib(s); |
| 832 |
// |
// |
| 852 |
TTree *tr = (TTree*)File->Get("CalibCalPed"); |
TTree *tr = (TTree*)File->Get("CalibCalPed"); |
| 853 |
if ( !tr ) return(-109); |
if ( !tr ) return(-109); |
| 854 |
// |
// |
|
TBranch *registry = tr->GetBranch("Registry"); |
|
| 855 |
TBranch *calo = tr->GetBranch("CalibCalPed"); |
TBranch *calo = tr->GetBranch("CalibCalPed"); |
| 856 |
// |
// |
|
pamela::RegistryEvent *reg = 0; |
|
| 857 |
pamela::CalibCalPedEvent *ce = 0; |
pamela::CalibCalPedEvent *ce = 0; |
| 858 |
tr->SetBranchAddress("CalibCalPed", &ce); |
tr->SetBranchAddress("CalibCalPed", &ce); |
|
tr->SetBranchAddress("Registry", ®); |
|
| 859 |
// |
// |
| 860 |
Long64_t ncalibs = registry->GetEntries(); |
Long64_t ncalibs = calo->GetEntries(); |
| 861 |
// |
// |
| 862 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
| 863 |
// |
// |
| 864 |
registry->GetEntry(calibno[s]); |
calo->GetEntry(calibno[s]); |
|
// |
|
|
calo->GetEntry(reg->event); |
|
| 865 |
// |
// |
| 866 |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
| 867 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
for ( Int_t d=0 ; d<11 ;d++ ){ |