// query the capacity of each channel
create procedure capacity_query 
is
@Chid number;
Begin
select capacity
from table capacity 
where Chid = @Chid;
end procdure 

// query the mean,sigma, third momentum, fourth momentum,fc and fs for 
a given run,gaintype and channel in the pedestal test

create procedure pdtest_mean_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select mean
from table pdtest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 



create procedure pdtest_sig_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select sig
from table pdtest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 

create procedure pdtest_fc_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select fc
from table pdtest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 

create procedure pdtest_fs_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select fs
from table pdtest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 



create procedure pdtest_sig3_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select sig3
from table pdtest2
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 

create procedure pdtest_sig4_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select sig4
from table pdtest2 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 


// query the mean,sigma, third momentum, fourth momentum,fc and fs for 
a given run,gaintype and channel in the pulser test

create procedure plstest_mean_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select mean
from table plstest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 



create procedure plstest_sig_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select sig
from table plstest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 



create procedure plstest_fc_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select fc
from table plstest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 

create procedure plstest_fs_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select fs
from table plstest 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 

create procedure plsnoise_sig3_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select sig3
from table plsnoise 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 


create procedure plsnoise_sig4_query 
is
@RunId number, @GainType number, @Chid number;
Begin
select sig4
from table plsnoise 
where RunId=@RunId and GainType=@GainType and Chid = @Chid;
end procdure 

// query the channel Ids for a given pulsertest pattern
create procedure pulserPattern_query
is
@PatternId number;
Begin
select chid
from table pulerPattern;
where PatternId=@PatternId;
end procdure 


// query the channel Ids for a given crate and ADCCard
create procedure setup_channel_query
is
@CrateId char(20), @CardId number;
Begin
select chid
from table setup 
where CrateId=@CrateId and CardId=@CardId;
end procdure 

// query the ADCCard Ids for a given crate
create procedure setup_ADCCard_query
is
@CrateId char(20);
Begin
select CardId
from table setup 
where CrateId=@CrateId;
end procdure 

//query the theta and phi for a given channel

create procedure geom_query
is
@ChId number;
Begin
select theta,phi
from table geom 
where ChId=@ChId;
end procdure 

// query the begin time and end time for a given run
create procedure calibtime_query
is
@RunId number;
Begin
select begin,end
from table calibtime 
where RunId=@RunId;
end procdure 

