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; |
91 |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); |
92 |
// |
// |
93 |
sgnl = 0; |
sgnl = 0; |
94 |
|
UInt_t uptime = 0; |
95 |
// |
// |
96 |
for (Int_t s = 0; s < 4; s++){ |
for (Int_t s = 0; s < 4; s++){ |
97 |
idcalib[s] = 0ULL; |
idcalib[s] = 0; |
98 |
fromtime[s] = 0ULL; |
fromtime[s] = 0; |
99 |
totime[s] = 0ULL; |
totime[s] = 0; |
100 |
calibno[s] = 0; |
calibno[s] = 0; |
101 |
ClearCalibVals(s); |
ClearCalibVals(s); |
102 |
// |
// |
103 |
sgnl = glcalo->Query_GL_CALO_CALIB(hs,s,dbc); |
sgnl = glcalo->Query_GL_CALO_CALIB(hs,uptime,s,dbc); |
104 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
105 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
106 |
return; |
return; |
107 |
}; |
}; |
108 |
// |
// |
109 |
idcalib[s] = glcalo->ID_REG_CALIBCALPED; |
idcalib[s] = glcalo->ID_ROOT_L0; |
110 |
fromtime[s] = glcalo->FROM_TIME; |
fromtime[s] = glcalo->FROM_TIME; |
111 |
totime[s] = glcalo->TO_TIME; |
if ( glcalo->TO_TIME < hs ){ // calibration is corrupted and we are using the one that preceed the good one |
112 |
calibno[s] = glcalo->EV_REG_CALIBCALPED; |
totime[s] = uptime; |
113 |
// |
} else { |
114 |
if ( totime[s] == 0ULL){ |
totime[s] = glcalo->TO_TIME; |
115 |
|
}; |
116 |
|
calibno[s] = glcalo->EV_ROOT; |
117 |
|
// |
118 |
|
if ( totime[s] == 0 ){ |
119 |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
120 |
ClearCalibVals(s); |
ClearCalibVals(s); |
121 |
sgnl = 100; |
sgnl = 100; |
128 |
if ( verbose ) printf("\n"); |
if ( verbose ) printf("\n"); |
129 |
for (Int_t s = 0; s < 4; s++){ |
for (Int_t s = 0; s < 4; s++){ |
130 |
if ( verbose ) printf(" ** SECTION %i **\n",s); |
if ( verbose ) printf(" ** SECTION %i **\n",s); |
131 |
if ( totime[s] > 0ULL ){ |
if ( totime[s] > 0 ){ |
132 |
// |
// |
133 |
sgnl = glroot->Query_GL_ROOT(idcalib[s],dbc); |
sgnl = glroot->Query_GL_ROOT(idcalib[s],dbc); |
134 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
135 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
136 |
return; |
return; |
137 |
}; |
}; |
138 |
// |
// |
139 |
stringstream name; |
stringstream name; |
140 |
name.str(""); |
name.str(""); |
141 |
name << glroot->PATH.Data() << "/"; |
name << glroot->PATH.Data() << "/"; |
142 |
name << glroot->NAME.Data(); |
name << glroot->NAME.Data(); |
143 |
// |
// |
144 |
fcalname[s] = (TString)name.str().c_str(); |
fcalname[s] = (TString)name.str().c_str(); |
145 |
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]); |
146 |
} else { |
} else { |
147 |
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); |
148 |
}; |
}; |
149 |
sgnl = LoadCalib(s); |
sgnl = LoadCalib(s); |
150 |
if ( sgnl ) break; |
if ( sgnl ) break; |
157 |
// |
// |
158 |
} |
} |
159 |
|
|
160 |
Int_t CaloProcessing::ChkCalib(TSQLServer *dbc, ULong64_t atime){ |
Int_t CaloProcessing::ChkCalib(TSQLServer *dbc, UInt_t atime){ |
161 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
162 |
for ( Int_t s = 0; s < 4; s++){ |
for ( Int_t s = 0; s < 4; s++){ |
163 |
if ( atime > totime[s] ){ |
if ( atime > totime[s] ){ |
168 |
return(sgnl); |
return(sgnl); |
169 |
} |
} |
170 |
|
|
171 |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, ULong64_t runheader){ |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, UInt_t runheader){ |
172 |
stringstream calfile; |
stringstream calfile; |
173 |
stringstream aligfile; |
stringstream aligfile; |
174 |
Int_t error = 0; |
Int_t error = 0; |
183 |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
184 |
// |
// |
185 |
error = 0; |
error = 0; |
186 |
error = glparam->Query_GL_PARAM(runheader,"Calorimeter ADC to MIP",dbc); |
error = glparam->Query_GL_PARAM(runheader,101,dbc); |
187 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
188 |
// |
// |
189 |
calfile.str(""); |
calfile.str(""); |
216 |
// |
// |
217 |
// |
// |
218 |
error = 0; |
error = 0; |
219 |
error = glparam->Query_GL_PARAM(runheader,"Calorimeter alignement",dbc); |
error = glparam->Query_GL_PARAM(runheader,102,dbc); |
220 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
221 |
// |
// |
222 |
aligfile.str(""); |
aligfile.str(""); |
245 |
}; |
}; |
246 |
// |
// |
247 |
delete glparam; |
delete glparam; |
|
// delete f; |
|
248 |
// |
// |
249 |
return(0); |
return(0); |
250 |
} |
} |
782 |
return; |
return; |
783 |
} |
} |
784 |
|
|
785 |
Int_t CaloProcessing::Update(TSQLServer *dbc, ULong64_t atime, Int_t s){ |
Int_t CaloProcessing::Update(TSQLServer *dbc, UInt_t atime, Int_t s){ |
786 |
// |
// |
787 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
788 |
// |
// |
790 |
// |
// |
791 |
sgnl = 0; |
sgnl = 0; |
792 |
// |
// |
793 |
idcalib[s] = 0ULL; |
idcalib[s] = 0; |
794 |
fromtime[s] = 0ULL; |
fromtime[s] = 0; |
795 |
totime[s] = 0ULL; |
totime[s] = 0; |
796 |
calibno[s] = 0; |
calibno[s] = 0; |
797 |
ClearCalibVals(s); |
ClearCalibVals(s); |
798 |
// |
// |
799 |
sgnl = glcalo->Query_GL_CALO_CALIB(atime,s,dbc); |
UInt_t uptime = 0; |
800 |
|
// |
801 |
|
sgnl = glcalo->Query_GL_CALO_CALIB(atime,uptime,s,dbc); |
802 |
if ( sgnl < 0 ){ |
if ( sgnl < 0 ){ |
803 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
804 |
return(sgnl); |
return(sgnl); |
805 |
}; |
}; |
806 |
// |
// |
807 |
idcalib[s] = glcalo->ID_REG_CALIBCALPED; |
idcalib[s] = glcalo->ID_ROOT_L0; |
808 |
fromtime[s] = glcalo->FROM_TIME; |
fromtime[s] = glcalo->FROM_TIME; |
809 |
totime[s] = glcalo->TO_TIME; |
if ( glcalo->TO_TIME < atime ){ // calibration is corrupted and we are using the one that preceed the good one |
810 |
calibno[s] = glcalo->EV_REG_CALIBCALPED; |
totime[s] = uptime; |
811 |
|
} else { |
812 |
|
totime[s] = glcalo->TO_TIME; |
813 |
|
}; |
814 |
|
// totime[s] = glcalo->TO_TIME; |
815 |
|
calibno[s] = glcalo->EV_ROOT; |
816 |
// |
// |
817 |
if ( totime[s] == 0ULL){ |
if ( totime[s] == 0 ){ |
818 |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
if ( verbose ) printf(" CALORIMETER - WARNING: data with no associated calibration\n"); |
819 |
ClearCalibVals(s); |
ClearCalibVals(s); |
820 |
sgnl = 100; |
sgnl = 100; |
838 |
name << glroot->NAME.Data(); |
name << glroot->NAME.Data(); |
839 |
// |
// |
840 |
fcalname[s] = (TString)name.str().c_str(); |
fcalname[s] = (TString)name.str().c_str(); |
841 |
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]); |
842 |
// |
// |
843 |
sgnl = LoadCalib(s); |
sgnl = LoadCalib(s); |
844 |
// |
// |
864 |
TTree *tr = (TTree*)File->Get("CalibCalPed"); |
TTree *tr = (TTree*)File->Get("CalibCalPed"); |
865 |
if ( !tr ) return(-109); |
if ( !tr ) return(-109); |
866 |
// |
// |
|
TBranch *registry = tr->GetBranch("Registry"); |
|
867 |
TBranch *calo = tr->GetBranch("CalibCalPed"); |
TBranch *calo = tr->GetBranch("CalibCalPed"); |
868 |
// |
// |
|
pamela::RegistryEvent *reg = 0; |
|
869 |
pamela::CalibCalPedEvent *ce = 0; |
pamela::CalibCalPedEvent *ce = 0; |
870 |
tr->SetBranchAddress("CalibCalPed", &ce); |
tr->SetBranchAddress("CalibCalPed", &ce); |
|
tr->SetBranchAddress("Registry", ®); |
|
871 |
// |
// |
872 |
Long64_t ncalibs = registry->GetEntries(); |
Long64_t ncalibs = calo->GetEntries(); |
873 |
// |
// |
874 |
if ( !ncalibs ) return(-110); |
if ( !ncalibs ) return(-110); |
875 |
// |
// |
876 |
registry->GetEntry(calibno[s]); |
calo->GetEntry(calibno[s]); |
|
// |
|
|
calo->GetEntry(reg->event); |
|
877 |
// |
// |
878 |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { |
879 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
for ( Int_t d=0 ; d<11 ;d++ ){ |