1 static const int Maxdet=4;
2 static const int Maxchl=578;
3 static const int Maxchs=288;
4 static const int Maxitr=20;
6 void bitshift(
int y=2015){
7 TFile *f = TFile::Open(
"DB.root");
8 TTree *t = (TTree*)f->Get(
"tr");
9 int year,iter,nstb,chan,bsft,offs,run,hts;
10 t->SetBranchAddress(
"year",&year);
11 t->SetBranchAddress(
"iter",&iter);
12 t->SetBranchAddress(
"nstb",&nstb);
13 t->SetBranchAddress(
"chan",&chan);
14 t->SetBranchAddress(
"bitshift",&bsft);
15 t->SetBranchAddress(
"offset",&offs);
16 t->SetBranchAddress(
"firstRun",&run);
17 t->SetBranchAddress(
"firstRunHTS",&hts);
19 short bs[Maxitr][Maxdet][Maxchl];
22 memset(bs,0,
sizeof(bs));
23 memset(runs,0,
sizeof(runs));
24 memset(nline,0,
sizeof(nline));
26 Long64_t n = t->GetEntries();
27 cout <<
"n="<<n<<endl;
29 for (Long64_t i=0; i<n; i++) {
32 if(maxiter<=iter) maxiter=iter;
33 printf(
"%4d %2d %2d %3d %3d %3d %4d %8d %8d\n",
34 i,year,iter,nstb,chan,bsft,offs,run,hts);
35 bs[iter][nstb-1][chan-1]=bsft;
41 printf(
"found up to iter=%d for run %d \n",maxiter,y);
44 for(
int it=0; it<=maxiter; it++){
45 if(nline[it]==0)
continue;
46 sprintf(file,
"fmsBitShiftGain_y%d_i%d_run%d.txt",y,it,runs[it][0]);
48 int nn=0, nup=0, ndn=0, nz=0;
49 if(fp=fopen(file,
"w")){
50 printf(
"Writing %s\n",file);
51 for(
int d=0; d<Maxdet; d++){
55 for(
int c=0; c<max; c++){
58 fprintf(fp,
"%2d %3d %2d\n",d+8,c+1,bs[it][d][c]);
60 if(bs[it][d][c]>0) nup++;
61 if(bs[it][d][c]<0) ndn++;
62 if(bs[it][d][c]==0) nz++;
66 printf(
"Closing %s\n",file);
67 printf(
"N=%d N_zero=%d N_positive=%d N_negative=%d\n",nn,nz,nup,ndn);
69 printf(
"Cannot openg %s\n",file);