#include #include #include #define _TOWERS_ 1 TH1F* cap0; TH2F* cor; TGraph *hist8; TH2F *hist9; TH2F *hist10; void plotPulseHF_TDC_ratio3(int nhtr=1, int nevt=-1) { gDirectory->DeleteAll(); ofstream out; TString outfile = "outs1.dat"; out.open(outfile); int runno; ////////////////// time_t t1; time(&t1); cout <<"time="<< t1<GetXaxis()->SetTimeDisplay(1); hist9=new TH2F(s9,s9, 1000,4416,4800,100,1.,3.); hist10=new TH2F(s10,s10, 1000,4416,4800,100,0.,1.2); // TH1F* pulses[24]; cap0=new TH1F("capIds","capIds",125,0,125); cor=new TH2F("cor","cor",700,3,10,500,1220,1270); // cor=new TH2F("cor","cor",100,4,7,1000,1000,10000); int slice = 6; TH1F *pulses[_TOWERS_]; TProfile *tpulses[_TOWERS_]; TProfile *ppulses[];///numan TH1F *ratios[_TOWERS_]; TH1F *totalEnergy; TH2F *totPulses, *mTiming; gStyle->SetOptStat(111111111); gStyle->SetOptFit(111111111); for (int i=0; i<_TOWERS_ ; i++) { char s[50]; //sprintf(s,"HTR#%d input %d",nhtr,i+1); //pulses[i]=new TH1F(s,s,20,-0.5,19.5); sprintf(s," Tower %d pedestal subtracted",i+1); pulses[i] = new TH1F( s, s, 20, -0.5, 19.5 ); pulses[i]->GetXaxis()->SetTitle("time slice"); sprintf(s," Tower %d Slice(%d)/Slice(%d) ratio",i+1,slice,slice+1); ratios[i] = new TH1F( s, s, 100, -0.5, 9.5 ); sprintf(s,"Slice(%d)/Slice(%d) ratio",slice,slice+1); ratios[i]->GetXaxis()->SetTitle(s); sprintf(s," Tower %d Slice(%d)/Slice(%d) ratio vs phase",i+1,slice,slice+1); tpulses[i] = new TProfile( s, s, 50,-10.5,50.*25./32.-10.5); tpulses[i]->GetXaxis()->SetTitle("Phase, ns"); } char str[100]; //sprintf(str,"Run %5d Trig Histo",runno); TH1F *trigh = new TH1F("trig histo",str,11,-1,10); //sprintf(str,"Run %5d Trig Histo2",runno); TH1F *trigh2 = new TH1F("trig histo2","TTC trig",200,3500,3700); TH1F *trigh3 = new TH1F("trig histo3","Laser trig",200,2200,2400); TH1F *trigh4 = new TH1F("trig histo4","phase",50,-10.5,50.*25./32.-10.5); double PAR[50000]=0.0; double RATIO[50000]=0.0; char filename[200]; for (int set = 1; set <= nlines; set++){ runno = runnumber[set]; sprintf(filename, "/home/numan/Data/RADDAM_data/raddam_firstpart/HTBhf_%06d.root", runno); printf(filename, "\n"); printf("\n"); TestBeamDataFile f; f.load(filename); PAR[set]=0.0; RATIO[set]=0.0; double totEvents = f.getNEvents(); int nEvents = 0; int goodEvents = 0; int badCaps = 0; int hardInfo[2] = {999,999}; int Nhits,aCon,aConC,Nhits_sv;; int Ntrbeam,Ntrttc; float Ntime,Time_beam,Time_ttc; aConC=0; float phase; int maxEvents = 10000; while( f.getNextEvent() && nEvents++ < maxEvents ) { aCon=0; Nhits=0; phase =-100; Ntrttc = f.getEventData()->getTDCData()->getNHitsInChannel(6); Ntrbeam = f.getEventData()->getTDCData()->getNHitsInChannel(5); trigh->Fill(Ntrbeam); //printf("NTTc=%d Nbeam=%d\n",Ntrttc,Ntrbeam); if(Ntrttc==1 && Ntrbeam==1) { Time_ttc = f.getEventData()->getTDCData()->getTimeInChannel(6,0); Time_beam = f.getEventData()->getTDCData()->getTimeInChannel(5,0); trigh2->Fill(Time_ttc); trigh3->Fill(Time_beam); phase = Time_beam-Time_ttc+1260.; trigh4->Fill(phase); } else continue; const DCCData* dcc=f.getEventData()->getHCALData()->getDCC(20); unsigned short buffer[25]; double data[20]; char fiber, qieid, er, dv, cap, qie; for (int nchan=1;nchan<2; nchan++) { int ntower = nchan; int samples=dcc->getQIEData(nhtr,nchan,buffer); // printf("DCC=%x Samples=%i\n",dcc,samples); double sum=0; double meantime=0; int cap_should_be=0; bool capok=true; for (int i=0; iFill(cap+(nchan-1)*5); // printf(" %d ",cap); // if(nchan==24) printf("\n"); } data[i]=DCCData::convertToFC_inv(qie); //data[i]=qie; if (i==0) cap_should_be=cap; else { cap_should_be=(cap_should_be+1)%4; if (cap_should_be!=cap) {capok=false; //printf("Bad capid!\n"); } } } if( capok ) { pedestal = 0; for(int tslice = 0; tslice <4; tslice++) { DCCData::parseQIE(buffer[tslice],fiber,qieid, er, dv, cap, qie); pedestal += dcc->convertToFC_inv(qie); } pedestal/=4.0; for(int tslice = 0; tslice < 20; tslice++) { DCCData::parseQIE(buffer[tslice],fiber,qieid, er, dv, cap, qie); // data[tslice] = dcc->convertToFC_noninv(qie)-pedestal; data[tslice] = dcc->convertToFC_inv(qie)-pedestal; pulses[ntower-1]->Fill( tslice, data[tslice] ); goodEvents++; } double ratio= 0.0; double p0=0.0; if((data[slice]>5.) && (data[slice+1]>5.)) ratio=data[slice]/data[slice+1]; tpulses[ntower-1]->SetLineWidth(1); tpulses[ntower-1]->SetLineStyle(1); tpulses[ntower-1]->SetLineColor(4); tpulses[ntower-1]->Fill(phase,ratio); g1 =new TF1("g1","pol0",7,18); g1->SetLineColor(2); tpulses[ntower-1]->Fit(g1,"R"); ratios[ntower-1]->Fill(ratio); } else { badCaps++; } } g1->GetParameters(&p0); } PAR[set]=p0; RATIO[set]=PAR[1]/PAR[set]; hist8->Set(hist8->GetN()+1); hist8->SetPoint(hist8->GetN()-1,TIME[set],PAR[set]); cout<<"time= "<GetXaxis()->SetTimeDisplay(1); hist8->GetXaxis()->SetTimeFormat("#splitline{%H:%M}{%d\/%m}"); hist8->Draw("alp"); }