6 #include <TClonesArray.h>
11 #include <StMessMgr.h>
13 #include "EEqaSorterA.h"
14 #include "StMuDSTMaker/EZTREE/EztEmcRawData.h"
25 memset(feePed,0,
sizeof(feePed));
29 EEqaSorterA::~EEqaSorterA() {
30 for(
int icr = 0;icr < MaxAnyCrate;icr++) {
31 if (hCrate && hCrate[icr])
delete hCrate[icr];
33 if (hCrate)
delete hCrate;
34 for(
int icr = 0;icr < MaxTwCrateID;icr++) {
35 if (hCrateHot && hCrateHot[icr])
delete hCrateHot[icr];
37 if (hCrateHot)
delete hCrateHot;
43 sortDaqMapmt0(s, ver);
48 void EEqaSorterA::Finish(){
58 for(
int icr=0;icr<t->getNBlocks() && icr<MaxTwCrateID;icr++) {
59 if(t->isCrateVoid(icr))
continue;
61 const UShort_t*
data=t->data(icr);
62 for(
int i=0;i<t->sizeData(icr) && i<MaxTwCrateCh;i++) {
65 if (hCrate && hCrate[crateID - 1]) hCrate[crateID - 1]->Fill(adc, chan);
77 for(
int icr=0;icr<t->getNBlocks() && icr<MaxTwCrateID;icr++) {
78 if(t->isCrateVoid(icr))
continue;
80 const UShort_t* data=t->data(icr);
81 int *pedA= &feePed[(crateID-1)*MaxTwCrateCh];
82 if (data)
for(
int i=0;i<t->sizeData(icr) && i<MaxTwCrateCh;i++) {
84 float adc=data[i]-24+ pedA[i];
85 if(adc<hotTwThres)
continue;
86 if (hCrateHot && hCrateHot[crateID-1]) hCrateHot[crateID-1]->Fill(chan);
92 void EEqaSorterA::sortDaqMapmt0(
const EztEmcRawData *s,
int ver){
97 for(
int icr=0;icr<s->getNBlocks();icr++) {
98 if(s->isCrateVoid(icr))
continue;
105 const UShort_t* data=s->data(icr);
106 for(
int i=0;i<s->sizeData(icr) && i<MaxMapmtCrateCh;i++) {
109 if (hCrate && hCrate[crateID-1]) hCrate[crateID-1]->Fill(adc,chan);
116 void EEqaSorterA::initCrateHisto(TObjArray *HList,
int nBin,
int mxADC) {
117 const char *sectL[]={
"11TD-1TC",
"1TD-3TC",
"3TD-5TC",
"5TD-7TC",
"7TD-9TC",
"9TD-11TC"};
118 LOG_DEBUG << Form(
" EEqaSorterA::initCrateHisto(nb=%d, max=%d)\n", nBin,mxADC) << endm;
121 hCrate =
new TH2F *[MaxAnyCrate];
122 for(
int icr=0;icr<MaxAnyCrate;icr++) {
128 if(crateID>=MinTwCrateID && crateID<=MaxTwCrateID) {
131 physDet=sectL[crateID-1];
132 }
else if (crateID>=MinMapmtCrateID && crateID<=MaxMapmtCrateID ){
134 mxChan=MaxMapmtCrateCh;
135 int sec=1+(7+crateID/4)%MaxSectors;
137 physDet = (box==4) ? Form(
"%dP1",sec) : Form(
"%dS%d",sec,box);
140 if(mxChan==0)
continue;
142 hCrate[icr] =
new TH2F(Form(
"cr%d",crateID),Form(
" %s",physDet.Data()),nBin,-0.5, mxADC-0.5, mxChan, -0.5, mxChan-0.5);
143 if (HList) HList->Add(hCrate[icr]);
146 hCrateHot =
new TH1F *[MaxTwCrateID];
147 for(
int icr=0;icr<MaxTwCrateID;icr++) {
150 int mxChan=MaxTwCrateCh;
151 hCrateHot[icr] =
new TH1F(Form(
"cr%dHot",crateID),Form(
"%s thr=feePed+%d",sectL[crateID-1],hotTwThres), mxChan, -0.5, mxChan-0.5);
152 hCrateHot[icr]->SetFillColor(kBlue);
153 if (HList) HList->Add(hCrateHot[icr]);
155 LOG_DEBUG <<
"Initialized " << nOK <<
" 2D carte-histos" << endm;
158 void EEqaSorterA::saveHisto(TFile *f)
const {
160 for(
int icr = 0;icr < MaxAnyCrate;icr++) {
161 if (hCrate && hCrate[icr]) hCrate[icr]->Write();
163 for(
int icr = 0;icr < MaxTwCrateID;icr++) {
164 if (hCrateHot && hCrateHot[icr]) hCrateHot[icr]->Write();
168 void EEqaSorterA::resetHisto() {
169 for(
int icr = 0;icr < MaxAnyCrate;icr++) {
170 if (hCrate && hCrate[icr]) hCrate[icr]->Reset();
172 for(
int icr = 0;icr < MaxTwCrateID;icr++) {
173 if (hCrateHot && hCrateHot[icr]) hCrateHot[icr]->Reset();
178 int EEqaSorterA::usePed4(
const Char_t *filename) {
181 LOG_DEBUG <<
" EEqaSorterA::usePed4(\"" << filename <<
"\") ..." << endm;
182 FILE *fd=fopen(filename,
"r");
185 for(
int cr=MinTwCrateID;cr<=MaxTwCrateID;cr++) {
186 for(
int ch=0;ch<MaxTwCrateCh; ch++) {
187 int xcr = -1, xch = -1, ped4 = 0;
189 int ret=fscanf(fd,
"%d %d %f %d",&xcr,&xch,&xped,&ped4);
190 if ((ret == 4) && (xcr >= MinTwCrateID) && (xcr <= MaxTwCrateID) && (xch >= 0) && (xch < MaxTwCrateCh)) {
191 feePed[(xcr - 1)*MaxTwCrateCh + xch]=4*ped4;
193 LOG_ERROR <<
"Bad format in " << filename <<
": read xcr=" << xcr <<
", xch=" << xch <<
", xped=" << xped <<
", ped4=" << ped4 <<
", ret=" << ret <<
"; expected xcr=" << cr <<
", xch=" << ch << endm;
200 LOG_DEBUG <<
" EEqaSorterA::usePed4(...) Loaded" << endm;
202 LOG_ERROR <<
"Cannot read file " << filename << endm;