#include #include #include #include "TPCRun.h" #include "TFile.h" #include "TH2F.h" #include "TH3F.h" #include "TStopwatch.h" int imin=30; int imax=500; TFile *fileroot; TH2F *hmean,*hrms,*htpc; TH3F *htpc3D; TStopwatch *stopwatch; int TPCRun::StartOfEvent(TPCData *data){ stopwatch->Start(kTRUE); return 0; } unsigned short xdata[1000]; static int neve=0; int TPCRun::EndOfEvent(TPCData *data){ std::cout << neve++; data->Print(); stopwatch->Stop(); std::cout << "Read: "<< stopwatch->RealTime() << " s " ; stopwatch->Start(kTRUE); TPCAltroChannel *ch; std::vector *chlist = data->GetChannels(); unsigned short rcuid=0, chid=0; unsigned short sector=0, row=0, pad=0; unsigned short sectorfecid=0; unsigned short fecsn=0; unsigned short rcurow=0; int ier=0; for (unsigned int i=0;i< chlist->size();i++){ ch = &(*chlist)[i]; //ch->Print(); ch->GetHardwareAddress(&rcuid, &chid); ier = fTPCMapping->GetPhysAddr(rcuid, chid, §or, &row, &pad); ier = fTPCMapping->GetInfo(rcuid,chid>>7, &fecsn, §orfecid, &rcurow); float mean,rms,x,y; ier = fTPCMapping->RowPad2XY(0,row,pad,&x,&y); y-=852.25; hmean->Fill(chid&0x7f,sectorfecid,mean); hrms->Fill(chid&0x7f,sectorfecid,rms); // htpc->Fill(x,y,mean); int nch=ch->GetDecoded(1000,xdata); ch->GetMeanAndRMS(nch, xdata, &mean, &rms, imin, imax); const int print=0; if (print){ fprintf(stdout,"[%d] %d %d nch=%d %f %f %f %f ",rcuid, chid>>7, chid&0x7f,nch, x,y,mean,rms); fprintf(stdout,"[%d] ir=%d ip=%d secfec=%d\n",sector, row, pad ,sectorfecid); } for (int k = 50; k< nch; k++){ float val=xdata[k]-mean+2*rms; if (val>0){ htpc->Fill(x,y,val); // htpc3D->Fill(x,y,k,val); } // fprintf(stdout,"==> %d %d\n",k,xdata[k]); } } stopwatch->Stop(); std::cout << "Analysis: "<< stopwatch->RealTime() << " s" << std::endl; return 0; } int TPCRun::StartOfRun(TPCData *data){ std::cout << "TPCRun::StartOfRun" << std::endl; fileroot = new TFile("test.root","RECREATE"); hrms = new TH2F("hrms","hrms",128,-0.5,127.5,43,-0.5,42.5); hmean = new TH2F("hmean","hmean",128,-0.5,127.5,43,-0.5,42.5); htpc = new TH2F("htpc","htpc",108,-216,216,62,0,472.5); htpc3D = new TH3F("htpc3d","htpc3d",108,-216,216,62,0,472.5,50,0,500); std::cout << "Histograms created" << std::endl; stopwatch = new TStopwatch(); return 0; } int TPCRun::EndOfRun(TPCData *data){ if (neve){ float scale=1/float(neve); hmean->Scale(scale); hrms->Scale(scale); } fileroot->Write(); fileroot->ls(); return 0; } TPCRun::TPCRun(TPCMapping *mapping){ fTPCMapping = mapping; std::cout << "new TPCMapping" << std::endl; std::cout << "TPCRun::TPCRun()" << std::endl; } TPCRun::~TPCRun(){ }