InfoChain Class Reference

#include <InfoChain.h>

List of all members.

Public Member Functions

 InfoChain ()
virtual ~InfoChain ()
virtual void AmalgInfoObjects (std::string infile, std::string outfile, Float_t outlength)
virtual void AmalgInfoObjects (std::string infile, std::string outfile, Float_t, Double_t ts)
virtual void ChainInfoFiles (std::string infile, std::string outfile)
virtual void CreateTables ()
virtual void DoStuff (std::string infile, std::string directory)
virtual void DrawGraphs (std::string infile, std::string directory)
virtual void TestDatabase () const
virtual void RemoveTemperatureEffects () const
virtual void MeasureNearTempResponse (const std::string filename) const
virtual void MeasureFarTempResponse (const std::string filename) const
virtual void WriteToMINOSDbi (std::string infile)
virtual void WriteToMINOSDbi (std::string infile, DetectorType::Detector_t detector, Int_t year, Int_t month, Int_t day, std::string recoversion)

Detailed Description

Definition at line 8 of file InfoChain.h.


Constructor & Destructor Documentation

InfoChain::InfoChain (  ) 

Definition at line 34 of file InfoChain.cxx.

00035 {/*
00036   fcDrift = new TCanvas("fcDrift",
00037                         "ADC drift as a function of time",
00038                         200,10,700,910);
00039   fcDrift->Divide(1,4);
00040  */
00041 }

InfoChain::~InfoChain (  )  [virtual]

Definition at line 43 of file InfoChain.cxx.

00044 {
00045 }


Member Function Documentation

virtual void InfoChain::AmalgInfoObjects ( std::string  infile,
std::string  outfile,
Float_t  ,
Double_t  ts 
) [virtual]
virtual void InfoChain::AmalgInfoObjects ( std::string  infile,
std::string  outfile,
Float_t  outlength 
) [virtual]
virtual void InfoChain::ChainInfoFiles ( std::string  infile,
std::string  outfile 
) [virtual]
void InfoChain::CreateTables (  )  [virtual]

Definition at line 76 of file InfoChain.cxx.

References DbiCascader::CreateStatement(), DbiStatement::ExecuteUpdate(), DbiTableProxyRegistry::GetCascader(), and DbiTableProxyRegistry::Instance().

00077 {
00078   int  dbNo = 0; // or whatever cascade entry you need
00079   DbiStatement* s = DbiTableProxyRegistry::Instance()
00080                         .GetCascader()
00081                         .CreateStatement(dbNo);
00082   s->ExecuteUpdate("create table if not exists CALDRIFTVLD ("
00083                    " SEQNO         int not null primary key auto_increment,"
00084                    " TIMESTART     datetime not null,"
00085                    " TIMEEND       datetime not null,"
00086                    " DETECTORMASK  tinyint,"
00087                    " SIMMASK       tinyint,"
00088                    " TASK          int,"
00089                    " AGGREGATENO   int,"
00090                    " CREATIONDATE  datetime not null,"
00091                    " INSERTDATE    datetime not null,"
00092                    " key TIMESTART (TIMESTART),"
00093                    " key TIMEEND (TIMEEND))");
00094   s->ExecuteUpdate("create table if not exists CALDRIFT ("
00095                    " SEQNO integer not null,"
00096                    " ROW_COUNTER integer not null,"
00097                    " BACKMEDIAN double,"
00098                    " BACKMEDIANERR double,"
00099                    " FRONTMEDIAN double,"
00100                    " FRONTMEDIANERR double,"
00101                    " NONFIDUCIALMEDIAN double,"
00102                    " NONFIDUCIALMEDIANERR double,"
00103                    " NUMMUONS integer,"
00104                    " NUMPLANES integer,"
00105                    " MEAN double,"
00106                    " MEANERR double,"
00107                    " MEDIAN double,"
00108                    " MEDIANERR double,"
00109                    " QUANTILE50 double,"
00110                    " RECOVERSION text,"
00111                    " DRIFTQUANTITY1 double,"
00112                    " DRIFTQUANTITY2 double,"
00113                    " primary key (SEQNO, ROW_COUNTER))");
00114   delete s;  //Drop statement to release connection.
00115   s = 0;
00116 
00117   cout << "Created the table." << endl;
00118 }

virtual void InfoChain::DoStuff ( std::string  infile,
std::string  directory 
) [virtual]
virtual void InfoChain::DrawGraphs ( std::string  infile,
std::string  directory 
) [virtual]
virtual void InfoChain::MeasureFarTempResponse ( const std::string  filename  )  const [virtual]
virtual void InfoChain::MeasureNearTempResponse ( const std::string  filename  )  const [virtual]
void InfoChain::RemoveTemperatureEffects (  )  const [virtual]

Definition at line 156 of file InfoChain.cxx.

References VldTimeStamp::Add(), Munits::day, CalDrift::GetMedian(), CalDrift::GetMedianErr(), DbiResultPtr< T >::GetNumRows(), CalDrift::GetRecoVersion(), DbiResultPtr< T >::GetRow(), VldTimeStamp::GetSec(), Dcs_Env_Near::GetTemp(), Dcs_Env_Far::GetTemp1(), Dcs_Env_Far::GetTemp2(), Munits::hour, SimFlag::kData, Dbi::kDefaultTask, kFar, Detector::kFar, kNear, Detector::kNear, Dbi::kTableMissing, Munits::minute, n, VldTimeStamp::Print(), and Dbi::SetTimeGate().

00157 {
00158   VldTimeStamp ts(2003,7,01,0,0,0); //Was time
00159   VldTimeStamp end(2006,4,01,0,0,0); // Was now
00160 
00161   //set the task to 1=Dogwood                                                   
00162   //all previous constants where in the default task=0                          
00163   Dbi::Task task = 1;
00164 
00165 //    VldTimeStamp ts(2005,12,01,0,0,0); //Was time
00166 //    VldTimeStamp end(2006,1,01,0,0,0); // Was now
00167   
00168   Double_t interval = 1.0*Munits::day;
00169   Int_t n = (Int_t) (((Double_t)(end-ts))/(interval) + 1.0);
00170   
00171   TGraphErrors driftNear(n);
00172   TGraphErrors driftFar(n);
00173   TGraphErrors corrNear(n);
00174   TGraphErrors corrFar(n);
00175   TGraphErrors tempsNear(n);
00176   TGraphErrors tempsFar(n);
00177   Int_t i = 0;
00178   
00179   
00180   const VldTimeStamp increment((Int_t) interval, 0);
00181   // const VldTimeStamp tref(2005,12,1,0,0,0);
00182   
00183   for (; ts<end; ts.Add(increment)){
00184     
00185     cout << "Now calibrating: ";
00186     ts.Print();
00187     
00188     //Get ND median:
00189     const VldContext vn(Detector::kNear,
00190                         SimFlag::kData,
00191                         ts);
00192     const DbiResultPtr<CalDrift> drpn("CALDRIFT",
00193                                       vn,
00194                                       task,
00195                                       Dbi::kTableMissing,
00196                                       false);
00197     Double_t median = 0.0;
00198     Double_t medianErr = 0.0;
00199     Double_t versionFactor = 1.0;
00200     if (drpn.GetNumRows()){
00201       const CalDrift* calD = drpn.GetRow(0);
00202       median = calD->GetMedian();
00203       medianErr = calD->GetMedianErr();
00204       cout << "Version: " << calD->GetRecoVersion() << endl;
00205       if ("R1_18_2" == calD->GetRecoVersion()){versionFactor = 1.0;}
00206     }
00207     Int_t time = ts.GetSec();
00208     driftNear.SetPoint(i,time,median*versionFactor);
00209     driftNear.SetPointError(i,12*Munits::hour,medianErr*versionFactor);
00210     
00211     //Get FD median:
00212     const VldContext vf(Detector::kFar,
00213                         SimFlag::kData,
00214                         ts);
00215     const DbiResultPtr<CalDrift> drpf("CALDRIFT",
00216                                       vf,
00217                                       task,
00218                                       Dbi::kTableMissing,
00219                                       false);
00220     median = 0.0;
00221     medianErr = 0.0;
00222     if (drpf.GetNumRows()){
00223       const CalDrift* calD = drpf.GetRow(0);
00224       median = calD->GetMedian();
00225       medianErr = calD->GetMedianErr();
00226       cout << "Version: " << calD->GetRecoVersion() << endl;
00227     }
00228     driftFar.SetPoint(i,time,median);
00229     driftFar.SetPointError(i,12*Munits::hour,medianErr);
00230     
00231     //Start the minute time loop for a better average temperature:
00232     VldTimeStamp ttemp(ts);
00233     VldTimeStamp ttempend(ts);
00234     ttempend.Add(increment);
00235     Double_t ntotTemp = 0;
00236     Double_t ntotTempSq = 0;
00237     Int_t nCounter = 0;
00238     Double_t ftotTemp = 0;
00239     Double_t ftotTempSq = 0;
00240     Int_t fCounter = 0;
00241     const VldTimeStamp tempincrement((Int_t) (1*Munits::minute), 0);
00242     for (; ttemp < ttempend; ttemp.Add(tempincrement)){
00243       
00244       //Get ND temperature:
00245       VldContext ndtemp(DetectorType::kNear, SimFlag::kData, ttemp);
00246       Dbi::SetTimeGate("DCS_ENV_NEAR",15*60);
00247       const DbiResultPtr<Dcs_Env_Near> drpn("DCS_ENV_NEAR", ndtemp,
00248                                             Dbi::kDefaultTask,
00249                                             Dbi::kTableMissing,
00250                                             false);
00251       Int_t numRows = drpn.GetNumRows();
00252       for (Int_t j=0; j<numRows; ++j){
00253         const Dcs_Env_Near* decn = drpn.GetRow(j);
00254         if (decn){
00255           Double_t t = decn->GetTemp();
00256           ntotTemp += t;
00257           ntotTempSq += t*t;
00258           ++nCounter;
00259         }
00260         else {
00261           cout << "No temperature!!!!" << endl;
00262         }//else
00263       }//for
00264       
00265       //Get FD temperature:
00266       VldContext fdtemp(DetectorType::kFar, SimFlag::kData, ttemp);
00267       Dbi::SetTimeGate("DCS_ENV_FAR",15*60);
00268       const DbiResultPtr<Dcs_Env_Far> drpf("DCS_ENV_FAR", fdtemp,
00269                                             Dbi::kDefaultTask,
00270                                             Dbi::kTableMissing,
00271                                             false);
00272       numRows = drpf.GetNumRows();
00273       for (Int_t j=0; j<numRows; ++j){
00274         const Dcs_Env_Far* decf = drpf.GetRow(j);
00275         if (decf){
00276           Double_t t = (decf->GetTemp1() + decf->GetTemp2())/2.0;
00277           ftotTemp += t;
00278           ftotTempSq += t*t;
00279           ++fCounter;
00280         }
00281         else {
00282           cout << "No temperature!!!!" << endl;
00283         }//else
00284       }//for
00285     }//for temperature loon
00286     Double_t nTemp = 0.0;
00287     Double_t nTempErr = 0.0;
00288     if (nCounter){
00289       nTemp = ntotTemp/nCounter;
00290       nTempErr = ((ntotTempSq/nCounter)
00291                   - (ntotTemp*ntotTemp)/(nCounter*nCounter))
00292         /(sqrt((Double_t) nCounter));
00293     }
00294     Double_t fTemp = 0.0;
00295     Double_t fTempErr = 0.0;
00296     if (fCounter){
00297       fTemp = ftotTemp/fCounter;
00298       fTempErr = ((ftotTempSq/fCounter)
00299                   - (ftotTemp*ftotTemp)/(fCounter*fCounter))
00300         /(sqrt((Double_t) fCounter));
00301     }
00302     
00303     tempsNear.SetPoint(i,time,nTemp);
00304     tempsNear.SetPointError(i,12*Munits::hour,nTempErr);
00305     tempsFar.SetPoint(i,time,fTemp);
00306     tempsFar.SetPointError(i,12*Munits::hour,fTempErr);
00307     
00308     ++i;
00309   }//for drift increment
00310   
00311   TCanvas cNear("cNear","Near Detector",10,10,1000,800);
00312   cNear.Divide(1,3);
00313   cNear.cd(1);
00314   driftNear.GetXaxis()->SetTimeDisplay(1);
00315   driftNear.GetXaxis()->SetTimeFormat("%d-%m-%y%F1970-01-01 00:00:00");
00316   driftNear.Draw("A*");
00317   cNear.cd(2);
00318   tempsNear.GetXaxis()->SetTimeDisplay(1);
00319   tempsNear.GetXaxis()->SetTimeFormat("%d-%m-%y%F1970-01-01 00:00:00");
00320   tempsNear.Draw("A*");
00321   //cNear.Print("NearTempCorr.C");
00322   
00323   TCanvas cFar("cFar","Far Detector",10,10,1000,800);
00324   cFar.Divide(1,3);
00325   cFar.cd(1);
00326   driftFar.GetXaxis()->SetTimeDisplay(1);
00327   driftFar.GetXaxis()->SetTimeFormat("%d-%m-%y%F1970-01-01 00:00:00");
00328   driftFar.Draw("A*");
00329   cFar.cd(2);
00330   tempsFar.GetXaxis()->SetTimeDisplay(1);
00331   tempsFar.GetXaxis()->SetTimeFormat("%d-%m-%y%F1970-01-01 00:00:00");
00332   tempsFar.Draw("A*");
00333 
00334   cNear.Print("$SRT_PRIVATE_CONTEXT/ScintCal/Graphs/Near.C");
00335   cFar.Print("$SRT_PRIVATE_CONTEXT/ScintCal/Graphs/Far.C");
00336   
00337   string ofilename = "$SRT_PRIVATE_CONTEXT/ScintCal/NearTempCorrGraphs.root";
00338   TFile fnear(ofilename.c_str(),"RECREATE");
00339   tempsNear.Write("Temperatures");
00340   driftNear.Write("Medians");
00341   fnear.Close();
00342   cout << "Written file " << ofilename << endl;
00343   
00344   ofilename = "$SRT_PRIVATE_CONTEXT/ScintCal/FarTempCorrGraphs.root";
00345   TFile ffar(ofilename.c_str(),"RECREATE");
00346   tempsFar.Write("Temperatures");
00347   driftFar.Write("Medians");
00348   ffar.Close();
00349   
00350 //   this->MeasureNearTempResponse(ofilename);
00351 //   this->MeasureFarTempResponse(ofilename);
00352 }

void InfoChain::TestDatabase (  )  const [virtual]

Definition at line 565 of file InfoChain.cxx.

References CalDrift::GetMedian(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), SimFlag::kData, Detector::kNear, Dbi::kTableMissing, and VldTimeStamp::Print().

00566 {
00567 
00568   //set the task to 1=Dogwood                                             
00569   //all previous constants where in the default task=0                     
00570   Dbi::Task task = 1;
00571 
00572   Double_t* timeperiod = new Double_t[2000];
00573   Double_t* nmedian = new Double_t[2000];
00574   Double_t* fmedian = new Double_t[2000];
00575   Int_t i = 0;
00576   for (Int_t month = 1; month < 13; ++month){
00577     for (Int_t day = 1; day < 32; ++day){
00578       if ((month == 4) || (month == 6) || (month == 9) || (month == 11)){
00579         if (day == 31){continue;}
00580       }
00581       if (month == 2){
00582         if (day > 28){continue;}
00583       }
00584       
00585       timeperiod[i] = (Double_t) i;
00586       
00587       const VldTimeStamp time(2005,month,day,6,0,0);
00588       time.Print();
00589       const VldContext vn(Detector::kNear,
00590                           SimFlag::kData,
00591                           time);
00592       const VldContext vf(Detector::kNear,
00593                           SimFlag::kData,
00594                           time);
00595       const DbiResultPtr<CalDrift> drpn("CALDRIFT",
00596                                        vn,
00597                                        task,
00598                                        Dbi::kTableMissing,
00599                                        false);
00600       if (drpn.GetNumRows()){
00601         const CalDrift* calD = drpn.GetRow(0);
00602         nmedian[i] = calD->GetMedian();
00603       }
00604       const DbiResultPtr<CalDrift> drpf("CALDRIFT",
00605                                        vf,
00606                                        task,
00607                                        Dbi::kTableMissing,
00608                                        false);
00609       if (drpf.GetNumRows()){
00610         const CalDrift* calD = drpf.GetRow(0);
00611         fmedian[i] = calD->GetMedian();
00612       }
00613       ++i;
00614     }
00615   }
00616   TGraph gn(i,timeperiod,nmedian);
00617   TGraph gf(i,timeperiod,fmedian);
00618   TCanvas c("c","Database stuff",10,10,1000,800);
00619   c.Divide(1,2);
00620 //   gn.GetXaxis()->SetTimeDisplay(1);
00621   gn.Draw("A*");
00622   c.cd(2);
00623 //   gf.GetXaxis()->SetTimeDisplay(1);
00624   gf.Draw("A*");
00625   c.Print("DatabaseTest.C");
00626 /*  
00627   //Get the temperature of this snarl for FD
00628   if (DetectorType::kFar == Detector){
00629     Dbi::SetTimeGate("DCS_ENV_FAR",15*60);
00630     const DbiResultPtr<Dcs_Env_Far> drp("DCS_ENV_FAR", vc,
00631                                         Dbi::kDefaultTask,
00632                                         Dbi::kTableMissing,
00633                                         false);
00634     Int_t numRows = drp.GetNumRows();
00635     
00636     for (Int_t i=0; i<numRows; ++i){
00637       const Dcs_Env_Far* dec = drp.GetRow(i);
00638       
00639       if (dec){
00640         Float_t temp1 = dec->GetTemp1();
00641         Float_t temp2 = dec->GetTemp2();
00642         temp = (temp1 + temp2)/2.0;
00643         MSG("ScintCalModule", Msg::kDebug) 
00644           << "Far Temperature: " << temp << endl;
00645       }
00646       else {
00647         MSG("ScintCalModule", Msg::kWarning) 
00648           << "No temperature!!!!" << endl;
00649       }//else
00650     }//for
00651   }//if kFar
00652 */
00653 }

virtual void InfoChain::WriteToMINOSDbi ( std::string  infile,
DetectorType::Detector_t  detector,
Int_t  year,
Int_t  month,
Int_t  day,
std::string  recoversion 
) [virtual]
virtual void InfoChain::WriteToMINOSDbi ( std::string  infile  )  [virtual]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1