// _ can be given a set of run numbers (which need not necessarily exist) // _ finds the adc pedestals for all these runs and writes them into seperate pedestal datafiles // ( data/L20-adc-ped-####.dat ) // _ these datafiles can be displayed with the macro l20_adc_ped_monitor.C // _ Attention: macro may take a LONG time when executed over a big set of run numbers. // Recommended maximum ~ 100 // Revisions: // _ Original code updated (4/09/04) // raw_adc() { gROOT->Reset(); // read in the data file numbers, put them in list[] int i, j, n1, n2, list[2000], nl; int arc=gApplication->Argc(); char** arv=gApplication->Argv(); for (i=0;i 0) list[nl++] = n1; if (k == 2 && n1 > 0 && n2>n1) for (int j=n1;jnList();il++) { char title[125]; int k,il,mean; int sect, pad, tb; // make arrays of hit counters and data int padhits[2][16]; float hitval[2][16][2]; // make arrays of pointers for all the histograms. TH1F *adcLEFT_top[16], *adcLEFT_bot[16] ; TH1F *adcRIGHT_top[16], *adcRIGHT_bot[16] ; // book the histograms for(k=0;k<16;k++) { sprintf(title,"L20[%d]_LEFT_ADC_top",k); TH1F *adcLEFT_top[k] = new TH1F(title,title,1000,-1.5,8998.5); sprintf(title,"L20[%d]_LEFT_ADC_bot",k); TH1F *adcLEFT_bot[k] = new TH1F(title,title,1000,-1.5,8998.5); sprintf(title,"L20[%d]_RIGHT_ADC_top",k); TH1F *adcRIGHT_top[k] = new TH1F(title,title,1000,-1.5,8998.5); sprintf(title,"L20[%d]_RIGHT_ADC_bot",k); TH1F *adcRIGHT_bot[k] = new TH1F(title,title,1000,-1.5,8998.5); } cout<<"\nProcessing "<DataFile(il)<<" ...\n"<AccessPathName(gOpt->DataFile(il), kReadPermission)) { cerr<<"file " << gOpt->DataFile(il) <<" does not exist or is not readable\n"; // continue; } else { Long_t myId, mySize, myFlags, myModtime; gSystem->GetPathInfo(gOpt->DataFile(il),&myId,&mySize,&myFlags,&myModtime); if (mySize==0) { cerr<<"file " << gOpt->DataFile(il) <<" does not contain any data\n"; // continue; } else { gRaw->Open(gOpt->DataFile(il)); gRaw->ReadNext(1); int nL20, nCC; for (int ctr=0 ; !gRaw->ReadNext() && ctr < gOpt->StopAtEvent(); ctr++) { if (ctr%50000==0) printf("\n%9d ", ctr); else if (ctr%10000==0) cout<<":"<GetL20nhits(); for (k=0;kGetL20sector(k); pad = gRaw->GetL20paddle(k); tb = gRaw->GetL20tb(k); //patch for new LADS numbering if (pad < 14) { sect = 0; } else if (pad > 13 && pad < 28) { pad -= 14; } padhits[sect][pad] = 0; hitval[sect][pad][tb] = 0; } for (k=0;kGetL20sector(k); pad = gRaw->GetL20paddle(k); tb = gRaw->GetL20tb(k); //patch for new LADS numbering if (pad < 14) { sect = 0; } else if (pad > 13 && pad < 28) { pad -= 14; } if (sect == 0 && tb == 0 && (gRaw->GetL20tdc(k) < 0 || gRaw->GetL20tdc(k) > 4096)&& gRaw->GetL20adc(k) < 1500){ padhits[sect][pad]++; hitval[sect][pad][tb]=gRaw->GetL20adc(k); } else if (sect == 0 && tb == 1 && (gRaw->GetL20tdc(k) < 0 || gRaw->GetL20tdc(k) > 4096)&& gRaw->GetL20adc(k) < 1500){ padhits[sect][pad]++; hitval[sect][pad][tb]=gRaw->GetL20adc(k); } else if (sect == 1 && tb == 0 && (gRaw->GetL20tdc(k) < 0 || gRaw->GetL20tdc(k) > 4096)&& gRaw->GetL20adc(k) < 1500){ padhits[sect][pad]++; hitval[sect][pad][tb]=gRaw->GetL20adc(k); } else if (sect == 1 && tb == 1 && (gRaw->GetL20tdc(k) < 0 || gRaw->GetL20tdc(k) > 4096) && gRaw->GetL20adc(k) < 1500){ padhits[sect][pad]++; hitval[sect][pad][tb]=gRaw->GetL20adc(k); } } // end loop over L20 hits for (k=0;kGetL20sector(k); pad = gRaw->GetL20paddle(k); tb = gRaw->GetL20tb(k); //patch for new LADS numbering if (pad < 14) { sect = 0; } else if (pad > 13 && pad < 28) { pad -= 14; } // Found good hits now "manually" fill histogram if (padhits[0][pad] >0 && tb==0 && hitval[0][pad][0] >0) { adcLEFT_top[pad]->Fill(hitval[0][pad][0]); } if (padhits[0][pad] >0 && tb==1 && hitval[0][pad][1] >0) { adcLEFT_bot[pad]->Fill(hitval[0][pad][1]); } if (padhits[1][pad] >0 && tb==0 && hitval[1][pad][0] >0) { adcRIGHT_top[pad]->Fill(hitval[1][pad][0]); } if (padhits[1][pad] >0 && tb==1 && hitval[1][pad][1] >0) { adcRIGHT_bot[pad]->Fill(hitval[1][pad][1]); } } // end loop over L20 hits } // loop on events gRaw->CodaRead.closedatafile(); // datafile output char run_number[4]; sprintf(run_number,"%d",list[il]); TString outfile("data/L20-adc-ped-"); outfile += run_number; outfile += ".dat"; ofstream out(outfile, ios::out); char head[300]; char txt[100]; sprintf(head,"!L20-adc-ped-%s\.dat\n!\n!L_R is Left vs Right detector and 0=Left 1=Right\n!T_B is Top vs Bottom detector and 0=Top 1=Bottom\n!Bar is Detector Bar Number\n!Pedestal is Pedestal Channel\n!",run_number); out<GetXaxis()->SetRangeUser(0,1500); mean = adcLEFT_top[k]->GetMean(); adcLEFT_top[k]->GetXaxis()->SetRangeUser(mean-200,mean+200); mean = adcLEFT_top[k]->GetMean(); sprintf(txt,"%d\t%d\t%d\t%d",0,0,k,mean); out<GetXaxis()->SetRangeUser(0,1500); mean = adcLEFT_bot[k]->GetMean(); adcLEFT_bot[k]->GetXaxis()->SetRangeUser(mean-200,mean+200); mean = adcLEFT_bot[k]->GetMean(); sprintf(txt,"%d\t%d\t%d\t%d",0,1,k,mean); out<GetXaxis()->SetRangeUser(0,1500); mean = adcRIGHT_top[k]->GetMean(); adcRIGHT_top[k]->GetXaxis()->SetRangeUser(mean-200,mean+200); mean = adcRIGHT_top[k]->GetMean(); sprintf(txt,"%d\t%d\t%d\t%d",1,0,k,mean); out<GetXaxis()->SetRangeUser(0,1500); mean = adcRIGHT_bot[k]->GetMean(); adcRIGHT_bot[k]->GetXaxis()->SetRangeUser(mean-200,mean+200); mean = adcRIGHT_bot[k]->GetMean(); sprintf(txt,"%d\t%d\t%d\t%d",1,1,k,mean); out<