diff --git a/examples/DBASE/raster_test.database b/examples/DBASE/raster_test.database index cb15f86e18e3de3afed20bfa2de3bc6b8c937dd8..76fef1a57294cfe9dbdcee523afd6367dc232077 100644 --- a/examples/DBASE/raster_test.database +++ b/examples/DBASE/raster_test.database @@ -5,6 +5,12 @@ g_ctp_parm_filename ="PARAM/general.param" g_decode_map_filename ="MAPS/raster_jun04.map" g_ctp_kinematics_filename ="DBASE/jan05.kinematics" + +52947 +g_ctp_parm_filename ="PARAM/general.param" +g_decode_map_filename ="MAPS/raster_jun04.map" +g_ctp_kinematics_filename ="DBASE/jan05.kinematics" + 52426 g_ctp_parm_filename ="DBASE/52426.param" g_decode_map_filename ="HCANA_MAPS/july04.map" diff --git a/examples/MAPS/raster_jun04.map b/examples/MAPS/raster_jun04.map index 439afcbab59c04de9b9c7e9602f09f0ab0ba32b0..8f0a847b40a23a9bce34258d71c275cde1e2190e 100644 --- a/examples/MAPS/raster_jun04.map +++ b/examples/MAPS/raster_jun04.map @@ -1980,17 +1980,18 @@ Slot= 5 ! ADC Second set of tubes on first two layers ! detector= 18 ! RASTER ! -! buddhini-w :To make things easier and consistent between detectors, we now use the plane and signal to identify the different raster signals 02-12-2014 +! buddhini-w :To make things easier and consistent between detectors, +! we now use the plane and signal to identify the different raster signals 02-12-2014 !.............................................................................. ! For raster : 0-->ADC X-sync ! 1-->ADC Y-signal ! 2-->ADC Y-sync ! 3-->ADC Y-signal - 12, 1, 1, 0 !ADC ROC#1 Sl#13 Ch#12 Fast Raster X-sync + 12, 2, 1, 0 !ADC ROC#1 Sl#13 Ch#12 Fast Raster X-sync 13, 2, 1, 1 !ADC ROC#1 Sl#13 Ch#13 Fast Raster X-signal - 14, 3, 1, 2 !ADC ROC#1 Sl#13 Ch#14 Fast Raster Y-sync - 15, 4, 1, 3 !ADC ROC#1 Sl#13 Ch#15 Fast Raster Y-signal + 14, 2, 1, 2 !ADC ROC#1 Sl#13 Ch#14 Fast Raster Y-sync + 15, 2, 1, 3 !ADC ROC#1 Sl#13 Ch#15 Fast Raster Y-signal ! detector= 6 ! GMISC ! diff --git a/examples/PARAM/hcana.param b/examples/PARAM/hcana.param index 2149ebbb9ffe882087b395203eaa1a586bfd0845..7b5579de585adb0ccd736c07a0a8e75f516899e9 100644 --- a/examples/PARAM/hcana.param +++ b/examples/PARAM/hcana.param @@ -83,7 +83,3 @@ sdc_fix_propcorr = 0 # Total number of PMTs in Gas Cherenkov detector. hcer_tot_pmts = 2 -# parameter list for the raster -# Maybe we can add this to geabm.param later ? - -rraster_signal_names = "xsync xsig ysync ysig" diff --git a/examples/mapedit_rasterbcm.pl b/examples/mapedit_rasterbcm.pl new file mode 100644 index 0000000000000000000000000000000000000000..f83b00ed30d187bc7e96606d58b6694f5b8867c5 --- /dev/null +++ b/examples/mapedit_rasterbcm.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl + +# Rewrite a Hall C style MAP file so that the Raster and BPM +# are separate detector types instead of being part of the +# MISC detector +# +# 08.04.2014 (saw) Modify just raster entries for now + +use POSIX qw(strftime); + +$RASTERID=18; +$BCMID=19; +$SWAPRASTERXY=1; + +$thedate = strftime( '%b %e, %Y', localtime ); + +$ifile = $ARGV[0]; +$ofile = $ARGV[1]; + +open(IFILE,"<$ifile"); +open(OFILE,">$ofile"); + +print OFILE "! $ofile Automatically generated $thedate\n"; +print OFILE "! from $ifile by $0\n"; + +# Insert comments defining the raster and BCM detector IDS +$ininiddefs=0; +while(<IFILE>) { + chomp; + $line = $_; + if($line=~/_ID/) { + $iniddefs=1; + } elsif ($iniddefs) { + if(not $line=~/_ID/ and not $line=~/:/) { + print OFILE "! RASTER_ID=$RASTERID ADC\n"; + print OFILE "! BCM_ID=$RASTERID ADC\n"; + print OFILE "$line\n"; + last; + } + } + print OFILE "$line\n"; +} + +# Copy the rest of the file, looking for the specific channels to +# edit +$detector=0; +while(<IFILE>) { + chomp; + $line = $_; + + if($line=~/^\s*DETECTOR=\s*(\d*)/i) { + $detector=$1; + print "$detector\n"; + print OFILE "$line\n"; + } elsif ($line=~/^\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*),\s*(\d*)\s*(.*)/) { + $comment = $5; + $channel = $1; + $plane = $2; + $element = $3; + $signal = $4; + if($comment=~"Fast Raster") { + $signal = -1; + if($comment=~"X-sync") { + $signal = 0; + } elsif ($comment=~"X-signal") { + $signal = 1; + } elsif ($comment=~"Y-sync") { + $signal = 2; + } elsif ($comment=~"Y-signal") { + $signal = 3; + } + if($signal>=0) { + if ($SWAPRASTERXY) { + $signal = ($signal+2) % 4; + } + print OFILE "detector=$RASTERID ! RASTER\n"; + print OFILE "!$line\n"; + print OFILE "$channel, 1, 1, $signal $comment\n"; + print OFILE "detector=$detector ! RASTER\n"; + } else { + print OFILE "$line\n"; + } + } else { + print OFILE "$line\n"; + } + } else { + print OFILE "$line\n"; + } +} +exit; + +%crates=(); + +$crate = 0; +$nsubadd = 0; +$bsub = 0; +$modtype = 0; +$slot = 0; +while(<>) { + $line=chomp; + if($line=/^\s*ROC=\s*(\d*)/i) { + $i++; + $crate = $1; + if(not $crates{$crate}) { + $slotlist={}; + $crates{$crate} = $slotlist; + } + $modtype = 0; + $slot = 0; + } elsif ($line=/^\s*nsubadd=\s*(\d*)/i) { + $nsubadd = $1; + $modtype = 0; + } elsif ($line=/^\s*bsub=\s*(\d*)/i) { + $bsub = $1; + $modtype = 0; + } elsif ($line=/^\s*slot=\s*(\d*)/i) { + $slot = $1; + $modtype = 0; + } elsif ($line=/^\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)/) { + if($modtype == 0) { # Slot not yet registered + if($nsubadd == 96) { + $modtype = 1877; + } elsif($nsubadd == 64) { + if($bsub == 16) { + $modtype = 1875; + } elsif($bsub == 17) { + $modtype = 1881; + } + } + if($modtype == 0) { + print "Unknown module Crate $crate, Slot $slot\n"; + } + $crates{$crate}{$slot} = $modtype; + # print "$crate $slot $modtype\n"; + } + } +} +print "# Hall C Crate map\n"; +foreach $crate (sort {$a <=> $b} keys %crates) { + print "==== Crate $crate type fastbus\n"; + print "# slot model clear header mask nchan ndata\n"; + foreach $slot (sort {$a <=> $b} keys %{ $crates{$crate}}) { + $modtype = $crates{$crate}{$slot}; + if($modtype == 1877) { + $ndata = 256; + } else { + $ndata = 64; + } + printf " %2d %d 1 0x0 0x0 %3d %d\n" + ,$slot,$modtype,$nsubadd, $ndata; + } +} + + diff --git a/examples/output_bpw.def b/examples/output_bpw.def index ff1e98565ded9021242ddbdb1a6c8f63ce7bbb66..0fc62484ef2387c8abe7993aa0daf637ecfc0457 100644 --- a/examples/output_bpw.def +++ b/examples/output_bpw.def @@ -175,7 +175,9 @@ TH1F hs2yfptime 'HODO s2y fptime' H.hod.2y.fptime 80 0 80 H.hod.hgoodstarttime TH1F starttime 'HODO start time' H.hod.starttime 80 0 80 H.hod.hgoodstarttime # Beam related ADC channels. eg. raster -TH1F rstrx_i 'Raster X Current' RB.raster.xcurrent 4000 -2000 2000 -TH1F rstry_i 'Raster Y Current' RB.raster.ycurrent 4000 -2000 2000 -TH1F rstrx_p 'Raster X Position' RB.raster.xpos 40 -20 20 -TH1F rstry_p 'Raster Y Position' RB.raster.ypos 40 -20 20 +TH1F frx_raw_adc 'Raster X Raw ADC' RB.raster.frx_raw_adc 1200 3200 4400 +TH1F fry_raw_adc 'Raster Y Raw ADC' RB.raster.fry_raw_adc 1200 3200 4400 +TH1F frx_adc 'Raster X ADC' RB.raster.frx_adc 1000 -500 500 +TH1F fry_adc 'Raster Y ADC' RB.raster.fry_adc 1000 -500 500 +TH1F frx 'Raster X Position' RB.raster.frx 100 -0.5 0.5 +TH1F fry 'Raster Y Position' RB.raster.fry 100 -0.5 0.5 diff --git a/examples/raster_test.C b/examples/raster_test.C index b707af63cc96745e2e9adeefe582f83f06c67e91..a28f4143692854df3c89ce19877887ad0285f3bd 100644 --- a/examples/raster_test.C +++ b/examples/raster_test.C @@ -5,9 +5,9 @@ // Steering script to test raster signal decoding // - Int_t RunNumber=50017; - char* RunFileNamePattern="daq04_%d.log.0"; - + Int_t RunNumber=52947; + char* RunFileNamePattern="/cache/mss/hallc/daq04/raw/daq04_52947.log.0"; + // Open the database // @@ -90,7 +90,7 @@ // Define the analysis parameters // analyzer->SetEvent(event); - analyzer->SetOutFile("raster_test.root"); + analyzer->SetOutFile("raster_compare_52947.root"); analyzer->SetOdefFile("output_bpw.def"); analyzer->SetCutFile("hodtest_cuts.def"); // optional analyzer->SetCountMode(2);// Counter event number same as gen_event_ID_number diff --git a/src/THcRaster.cxx b/src/THcRaster.cxx index 0d8aa4c728d58621b7c2a426751353ee67064668..5e855514e011d67246156d4c53630c61594517be 100644 --- a/src/THcRaster.cxx +++ b/src/THcRaster.cxx @@ -40,6 +40,8 @@ THcRaster::THcRaster( const char* name, const char* description, fAnalyzePedestals = 0; fNPedestalEvents = 0; + fRawXADC = 0; + fRawYADC = 0; fXADC = 0; fYADC = 0; fXpos = 0; @@ -58,29 +60,19 @@ THcRaster::THcRaster( const char* name, const char* description, //_____________________________________________________________________________ THcRaster::~THcRaster() { - // delete [] fPedADC; - // delete [] fAvgPedADC; - + delete [] fPedADC; + delete [] fAvgPedADC; } - -//____________________________________________________________________________// _ -// void THcRaster::InitializeReconstruction() -// { - -// } - - + //_____________________________________________________________________________ Int_t THcRaster::ReadDatabase( const TDatime& date ) { // Read parameters such as calibration factor, of this detector from the database. - // static const char* const here = "THcRaster::ReadDatabase"; - - // InitializeReconstruction(); + cout << "THcRaster::ReadDatabase()" << endl; char prefix[2]; @@ -121,10 +113,12 @@ Int_t THcRaster::DefineVariables( EMode mode ) // Register variables in global list RVarDef vars[] = { - {"xcurrent", "Raster X current", "fXADC"}, - {"ycurrent", "Raster Y current", "fYADC"}, - {"xpos", "Raster X position", "fXpos"}, - {"ypos", "Raster Y position", "fYpos"}, + {"frx_raw_adc", "Raster X raw ADC", "fRawXADC"}, + {"fry_raw_adc", "Raster Y raw ADC", "fRawYADC"}, + {"frx_adc", "Raster X ADC", "fXADC"}, + {"fry_adc", "Raster Y ADC", "fYADC"}, + {"frx", "Raster X position", "fXpos"}, + {"fry", "Raster Y position", "fYpos"}, { 0 } }; @@ -258,13 +252,13 @@ Int_t THcRaster::Decode( const THaEvData& evdata ) THcRasterRawHit* hit = (THcRasterRawHit *) fRawHitList->At(ihit); if(hit->fADC_xsig>0) { - fRawADC[0] = hit->fADC_xsig; - // std::cout<<" Raw X = "<<fRawADC[0]<<std::endl; + fRawXADC = hit->fADC_xsig; + //std::cout<<" Raw X ADC = "<<fRawXADC<<std::endl; } if(hit->fADC_ysig>0) { - fRawADC[1] = hit->fADC_ysig; - // std::cout<<" Raw Y ADC = "<<fRawADC[1]<<std::endl; + fRawYADC = hit->fADC_ysig; + //std::cout<<" Raw Y ADC = "<<fRawYADC<<std::endl; } ihit++; } @@ -280,8 +274,7 @@ Int_t THcRaster::Decode( const THaEvData& evdata ) //_____________________________________________________________________________ Int_t THcRaster::Process( ){ - Double_t tmp = 0; - Double_t eBeam = 0; + Double_t eBeam = 0.001; /* calculate raster position from ADC value. From ENGINE/g_analyze_misc.f - @@ -291,8 +284,8 @@ Int_t THcRaster::Process( ){ */ // calculate the raster currents - fXADC = fRawADC[0]-fAvgPedADC[0]; - fYADC = fRawADC[1]-fAvgPedADC[1]; + fXADC = fRawXADC-fAvgPedADC[0]; + fYADC = fRawYADC-fAvgPedADC[1]; //std::cout<<" Raw X ADC = "<<fXADC<<" Raw Y ADC = "<<fYADC<<std::endl; /* @@ -301,14 +294,10 @@ Int_t THcRaster::Process( ){ gfrx = (gfrx_adc/gfrx_adcpercm)*(gfr_cal_mom/ebeam) gfry = (gfry_adc/gfry_adcpercm)*(gfr_cal_mom/ebeam) */ - // bpw- Iam not sure how to access the global variables. the below code doesnt work. so for now, hard code the beam energy. - eBeam=0.0001; + if(gHcParms->Find("gpbeam")){ eBeam=*(Double_t *)gHcParms->Find("gpbeam")->GetValuePointer(); } - // cout <<"e Beam = "<< eBeam << " " << fgpbeam << endl; - - // eBeam = 4.02187; fXpos = (fXADC/fFrXADCperCM)*(fFrCalMom/eBeam); fYpos = (fYADC/fFrYADCperCM)*(fFrCalMom/eBeam); diff --git a/src/THcRaster.h b/src/THcRaster.h index 31176483afdd833a30aab302ad7619d279143eed..29d3f0829b1f2fe273a78c8d173e1cef45891b4a 100644 --- a/src/THcRaster.h +++ b/src/THcRaster.h @@ -40,14 +40,16 @@ class THcRaster : public THaBeamDet, public THcHitList { Int_t ReadDatabase( const TDatime& date ); Int_t DefineVariables( EMode mode ); - Double_t fgpbeam; // + Double_t fgpbeam; //beam momentum - Double_t fXADC; // X current - Double_t fYADC; // Y current + Double_t fRawXADC; // X raw ADC + Double_t fRawYADC; // Y raw ADC + Double_t fXADC; // X ADC + Double_t fYADC; // Y ADC Double_t fXpos; // X position Double_t fYpos; // Y position - Double_t fRawADC[2]; // raw ADC values + Double_t fPedADC[2]; // ADC poedestals Double_t fAvgPedADC[2]; // Avergage ADC poedestals