ScintCalTimePeriod Class Reference

#include <ScintCalTimePeriod.h>

List of all members.

Public Member Functions

 ScintCalTimePeriod ()
 ScintCalTimePeriod (const UInt_t timeperiod, Double_t length)
 ScintCalTimePeriod (const ScintCalTimePeriod &original)
virtual ~ScintCalTimePeriod ()
ScintCalTimePeriodoperator= (const ScintCalTimePeriod &original)
ScintCalTimePeriod operator+ (const ScintCalTimePeriod &additive)
virtual Double_t BackMedian () const
virtual Double_t BackMedianErr () const
virtual DetectorType::Detector_t Detector () const
virtual void DrawHists () const
virtual void DisassociateHists () const
virtual Double_t EMeanTemperature () const
virtual Double_t EPeak ()
virtual Double_t FrontMedian () const
virtual Double_t FrontMedianErr () const
virtual Float_t Length () const
virtual Double_t Mean () const
virtual Double_t MeanTemperature () const
virtual Double_t Median () const
virtual void NewMuon ()
virtual Double_t NonFiducialMedian () const
virtual Double_t NonFiducialMedianErr () const
virtual UInt_t NumHits () const
virtual UInt_t NumMuons () const
virtual Double_t Peak ()
virtual void SetBinLength (const Double_t binLength)
virtual void SetTimePeriod (const UInt_t timeperiod)
virtual Double_t Sigma () const
virtual Double_t SigOvRtN () const
virtual void SingleHitUpdate (const ScintCalData &data)
virtual void SingleTempUpdate (const Float_t temp)
virtual CalDrift TableRow ()
virtual UInt_t TimePeriod () const
virtual void WriteToMINOSDbi ()
virtual void WriteToMINOSDbi (DetectorType::Detector_t detector, Int_t year, Int_t month, Int_t day, string recoversion)

Private Attributes

DetectorType::Detector_t fdetector
Double_t flength
UInt_t ftimePeriod
ScintCalInfo fBestInfo
ScintCalInfo fNonFiducialInfo
ScintCalInfo fFrontInfo
ScintCalInfo fBackInfo

Detailed Description

Definition at line 13 of file ScintCalTimePeriod.h.


Constructor & Destructor Documentation

ScintCalTimePeriod::ScintCalTimePeriod (  ) 

Definition at line 25 of file ScintCalTimePeriod.cxx.

00026   : TObject(),
00027     fdetector(DetectorType::kUnknown),
00028     flength(0.0),
00029     ftimePeriod(0),
00030     fBestInfo("Best"),
00031     fNonFiducialInfo("NonFiducial"),
00032     fFrontInfo("Front"),
00033     fBackInfo("Back")
00034 {
00035 }

ScintCalTimePeriod::ScintCalTimePeriod ( const UInt_t  timeperiod,
Double_t  length 
)

Definition at line 38 of file ScintCalTimePeriod.cxx.

00040   : TObject(),
00041     fdetector(DetectorType::kUnknown),
00042     flength(length),
00043     ftimePeriod(timeperiod),
00044     fBestInfo(timeperiod, length, "Best"),
00045     fNonFiducialInfo(timeperiod, length, "NonFiducial"),
00046     fFrontInfo(timeperiod, length, "Front"),
00047     fBackInfo(timeperiod, length, "Back")
00048 {
00049 }

ScintCalTimePeriod::ScintCalTimePeriod ( const ScintCalTimePeriod original  ) 

Definition at line 52 of file ScintCalTimePeriod.cxx.

00053   : TObject(),
00054     fdetector(original.fdetector),
00055     flength(original.flength),
00056     ftimePeriod(original.ftimePeriod),
00057     fBestInfo(original.fBestInfo),
00058     fNonFiducialInfo(original.fNonFiducialInfo),
00059     fFrontInfo(original.fFrontInfo),
00060     fBackInfo(original.fBackInfo)
00061 {
00062 }

ScintCalTimePeriod::~ScintCalTimePeriod (  )  [virtual]

Definition at line 65 of file ScintCalTimePeriod.cxx.

00066 {
00067 }


Member Function Documentation

Double_t ScintCalTimePeriod::BackMedian (  )  const [virtual]

Definition at line 122 of file ScintCalTimePeriod.cxx.

References fBackInfo, and ScintCalInfo::Median().

00123 {
00124   return fBackInfo.Median();
00125 }

Double_t ScintCalTimePeriod::BackMedianErr (  )  const [virtual]

Definition at line 128 of file ScintCalTimePeriod.cxx.

References ScintCalInfo::EMedian(), and fBackInfo.

00129 {
00130   return fBackInfo.EMedian();
00131 }

DetectorType::Detector_t ScintCalTimePeriod::Detector ( void   )  const [virtual]

Definition at line 134 of file ScintCalTimePeriod.cxx.

References fdetector.

Referenced by WriteToMINOSDbi().

00135 {
00136   return fdetector;
00137 }

void ScintCalTimePeriod::DisassociateHists (  )  const [virtual]
void ScintCalTimePeriod::DrawHists (  )  const [virtual]

Definition at line 140 of file ScintCalTimePeriod.cxx.

References ScintCalInfo::DrawHist(), and fBestInfo.

00141 {
00142   fBestInfo.DrawHist();
00143   return;
00144 }

Double_t ScintCalTimePeriod::EMeanTemperature (  )  const [virtual]

Definition at line 157 of file ScintCalTimePeriod.cxx.

References ScintCalInfo::EMeanTemperature(), and fBestInfo.

00158 {
00159   return fBestInfo.EMeanTemperature();
00160 }

Double_t ScintCalTimePeriod::EPeak (  )  [virtual]

Definition at line 163 of file ScintCalTimePeriod.cxx.

References ScintCalInfo::EPeak(), and fBestInfo.

00164 {
00165   return fBestInfo.EPeak();
00166 }

Double_t ScintCalTimePeriod::FrontMedian (  )  const [virtual]

Definition at line 169 of file ScintCalTimePeriod.cxx.

References fFrontInfo, and ScintCalInfo::Median().

00170 {
00171   return fFrontInfo.Median();
00172 }

Double_t ScintCalTimePeriod::FrontMedianErr (  )  const [virtual]

Definition at line 175 of file ScintCalTimePeriod.cxx.

References ScintCalInfo::EMedian(), and fFrontInfo.

00176 {
00177   return fFrontInfo.EMedian();
00178 }

Float_t ScintCalTimePeriod::Length (  )  const [virtual]

Definition at line 181 of file ScintCalTimePeriod.cxx.

References flength.

Referenced by ScintCalDatabase::InfoObjectUpdate(), and WriteToMINOSDbi().

00182 {
00183   return flength;
00184 }

Double_t ScintCalTimePeriod::Mean (  )  const [virtual]

Definition at line 187 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::Mean().

00188 {
00189   return fBestInfo.Mean();
00190 }

Double_t ScintCalTimePeriod::MeanTemperature (  )  const [virtual]

Definition at line 193 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::MeanTemperature().

00194 {
00195   return fBestInfo.MeanTemperature();
00196 }

Double_t ScintCalTimePeriod::Median (  )  const [virtual]

Definition at line 199 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::Median().

00200 {
00201   return fBestInfo.Median();
00202 }

void ScintCalTimePeriod::NewMuon (  )  [virtual]

Definition at line 205 of file ScintCalTimePeriod.cxx.

References fBackInfo, fBestInfo, fFrontInfo, fNonFiducialInfo, and ScintCalInfo::NewMuon().

00206 {
00207   fBestInfo.NewMuon();
00208   fNonFiducialInfo.NewMuon();
00209   fFrontInfo.NewMuon();
00210   fBackInfo.NewMuon();
00211   return;
00212 }

Double_t ScintCalTimePeriod::NonFiducialMedian (  )  const [virtual]

Definition at line 215 of file ScintCalTimePeriod.cxx.

References fNonFiducialInfo, and ScintCalInfo::Median().

00216 {
00217   return fNonFiducialInfo.Median();
00218 }

Double_t ScintCalTimePeriod::NonFiducialMedianErr (  )  const [virtual]

Definition at line 221 of file ScintCalTimePeriod.cxx.

References ScintCalInfo::EMedian(), and fNonFiducialInfo.

00222 {
00223   return fNonFiducialInfo.EMedian();
00224 }

UInt_t ScintCalTimePeriod::NumHits (  )  const [virtual]

Definition at line 226 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::NumPlanes().

00227 {
00228   return fBestInfo.NumPlanes();
00229 }

UInt_t ScintCalTimePeriod::NumMuons (  )  const [virtual]

Definition at line 232 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::NumMuons().

00233 {
00234   return fBestInfo.NumMuons();
00235 }

ScintCalTimePeriod ScintCalTimePeriod::operator+ ( const ScintCalTimePeriod additive  ) 

Definition at line 85 of file ScintCalTimePeriod.cxx.

References fBackInfo, fBestInfo, fdetector, fFrontInfo, flength, fNonFiducialInfo, ftimePeriod, Msg::kWarning, and MSG.

00086 {
00087   ScintCalTimePeriod temp;
00088   
00089   if(fdetector){
00090     if (fdetector != additive.fdetector){
00091       MSG("ScintCalTimePeriod", Msg::kWarning)
00092         << "This detector " << fdetector << " The other " << additive.fdetector
00093         << "Trying to amalgamate objects from different detectors"
00094         << endl;
00095       return temp;
00096     }
00097   }
00098   if (ftimePeriod != additive.ftimePeriod){
00099     MSG("ScintCalTimePeriod", Msg::kWarning)
00100       << "Trying to amalgamate objects from different time periods"
00101       << endl;
00102     return temp;
00103   }
00104   if (flength != additive.flength){
00105     MSG("ScintCalTimePeriod", Msg::kWarning)
00106       << "Trying to amalgamate objects with different lengths"
00107       << endl;
00108     return temp;
00109   }
00110   
00111   temp.fdetector = fdetector;
00112   temp.flength = flength;
00113   temp.ftimePeriod = ftimePeriod;
00114   temp.fBestInfo = fBestInfo + additive.fBestInfo;
00115   temp.fNonFiducialInfo = fNonFiducialInfo + additive.fNonFiducialInfo;
00116   temp.fFrontInfo = fFrontInfo + additive.fFrontInfo;
00117   temp.fBackInfo = fBackInfo + additive.fBackInfo;
00118   return temp;
00119 }

ScintCalTimePeriod & ScintCalTimePeriod::operator= ( const ScintCalTimePeriod original  ) 

Definition at line 70 of file ScintCalTimePeriod.cxx.

References fBackInfo, fBestInfo, fdetector, fFrontInfo, flength, fNonFiducialInfo, and ftimePeriod.

00071 {
00072   if (this != &original){
00073     fdetector = original.fdetector;
00074     flength = original.flength;
00075     ftimePeriod = original.ftimePeriod;
00076     fBestInfo = original.fBestInfo;
00077     fNonFiducialInfo = original.fNonFiducialInfo;
00078     fFrontInfo = original.fFrontInfo;
00079     fBackInfo = original.fBackInfo;
00080   }
00081   return *this;
00082 }

Double_t ScintCalTimePeriod::Peak (  )  [virtual]

Definition at line 237 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::Peak().

00238 {
00239   return fBestInfo.Peak();
00240 }

void ScintCalTimePeriod::SetBinLength ( const Double_t  binLength  )  [virtual]

Definition at line 243 of file ScintCalTimePeriod.cxx.

References fBackInfo, fBestInfo, fFrontInfo, flength, fNonFiducialInfo, and ScintCalInfo::SetBinLength().

00244 {
00245   flength = binLength;
00246   fBestInfo.SetBinLength(binLength);
00247   fNonFiducialInfo.SetBinLength(binLength);
00248   fFrontInfo.SetBinLength(binLength);
00249   fBackInfo.SetBinLength(binLength);
00250   return;
00251 }

void ScintCalTimePeriod::SetTimePeriod ( const UInt_t  timeperiod  )  [virtual]

Definition at line 254 of file ScintCalTimePeriod.cxx.

References fBackInfo, fBestInfo, fFrontInfo, fNonFiducialInfo, ftimePeriod, and ScintCalInfo::SetTimePeriod().

00255 {
00256   ftimePeriod = timeperiod;
00257   fBestInfo.SetTimePeriod(timeperiod);
00258   fNonFiducialInfo.SetTimePeriod(timeperiod);
00259   fFrontInfo.SetTimePeriod(timeperiod);
00260   fBackInfo.SetTimePeriod(timeperiod);
00261   return;
00262 }

Double_t ScintCalTimePeriod::Sigma (  )  const [virtual]

Definition at line 265 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::Sigma().

00266 {
00267   return fBestInfo.Sigma();
00268 }

Double_t ScintCalTimePeriod::SigOvRtN (  )  const [virtual]

Definition at line 271 of file ScintCalTimePeriod.cxx.

References fBestInfo, and ScintCalInfo::SigOvRtN().

00272 {
00273   return fBestInfo.SigOvRtN();
00274 }

void ScintCalTimePeriod::SingleHitUpdate ( const ScintCalData data  )  [virtual]

Definition at line 277 of file ScintCalTimePeriod.cxx.

References ScintCalData::Date(), ScintCalData::Detector(), fBackInfo, fBestInfo, fdetector, fFrontInfo, ScintCalData::Fiducial(), fNonFiducialInfo, Msg::kInfo, kUnknown, Msg::kWarning, MAXMSG, MSG, ScintCalData::PH(), ScintCalInfo::SingleHitUpdate(), and ScintCalData::ZRegion().

00278 {
00279   MAXMSG("ScintCalTimePeriod", Msg::kInfo,10)
00280     <<"ScintCalTimePeriod::SingleHitUpdate " << data.Date() 
00281     << " fiducial " << data.Fiducial()
00282     << " zregion " << data.ZRegion()
00283     << " ph " << data.PH()
00284     << endl;
00285 
00286   if (DetectorType::kUnknown != fdetector){
00287     if (data.Detector() != fdetector){
00288       MSG("ScintCalTimePeriod", Msg::kWarning)
00289         << "Trying to add data from the wrong detector!"
00290         << endl;
00291       return;
00292     }
00293   }
00294   else {fdetector = data.Detector();}
00295   fNonFiducialInfo.SingleHitUpdate(data.PH());
00296   if (data.Fiducial()){
00297     fBestInfo.SingleHitUpdate(data.PH());
00298     if (0 == data.ZRegion()){fFrontInfo.SingleHitUpdate(data.PH());}
00299     if (1 == data.ZRegion()){fBackInfo.SingleHitUpdate(data.PH());}
00300   }
00301 }

void ScintCalTimePeriod::SingleTempUpdate ( const Float_t  temp  )  [virtual]

Definition at line 304 of file ScintCalTimePeriod.cxx.

References fBackInfo, fBestInfo, fFrontInfo, fNonFiducialInfo, and ScintCalInfo::SingleTempUpdate().

00305 {
00306   fBestInfo.SingleTempUpdate(temp);
00307   fNonFiducialInfo.SingleTempUpdate(temp);
00308   fFrontInfo.SingleTempUpdate(temp);
00309   fBackInfo.SingleTempUpdate(temp);
00310   return;
00311 }

CalDrift ScintCalTimePeriod::TableRow (  )  [virtual]

Definition at line 314 of file ScintCalTimePeriod.cxx.

References ScintCalInfo::EMean(), ScintCalInfo::EMedian(), fBackInfo, fBestInfo, fFrontInfo, fNonFiducialInfo, ScintCalInfo::Mean(), ScintCalInfo::Median(), ScintCalInfo::NumMuons(), ScintCalInfo::NumPlanes(), ScintCalInfo::Quantile50(), CalDrift::SetBackMedian(), CalDrift::SetBackMedianErr(), CalDrift::SetFrontMedian(), CalDrift::SetFrontMedianErr(), CalDrift::SetMean(), CalDrift::SetMeanErr(), CalDrift::SetMedian(), CalDrift::SetMedianErr(), CalDrift::SetNonFidMedian(), CalDrift::SetNonFidMedianErr(), CalDrift::SetNumMuons(), CalDrift::SetNumPlanes(), and CalDrift::SetQuantile50().

Referenced by WriteToMINOSDbi().

00315 {
00316   CalDrift tableRow;
00317   tableRow.SetBackMedian(fBackInfo.Median());
00318   tableRow.SetBackMedianErr(fBackInfo.EMedian());
00319   tableRow.SetFrontMedian(fFrontInfo.Median());
00320   tableRow.SetFrontMedianErr(fFrontInfo.EMedian());
00321   tableRow.SetNonFidMedian(fNonFiducialInfo.Median());
00322   tableRow.SetNonFidMedianErr(fNonFiducialInfo.EMedian());
00323   tableRow.SetNumMuons((Int_t) fBestInfo.NumMuons());
00324   tableRow.SetNumPlanes((Int_t) fBestInfo.NumPlanes());
00325   tableRow.SetMean(fBestInfo.Mean());
00326   tableRow.SetMeanErr(fBestInfo.EMean());
00327   tableRow.SetMedian(fBestInfo.Median());
00328   tableRow.SetMedianErr(fBestInfo.EMedian());
00329   tableRow.SetQuantile50(fBestInfo.Quantile50());
00330   //tableRow.SetPeak(fBestInfo.Peak());
00331   //tableRow.SetPeakErr(fBestInfo.EPeak());
00332 return tableRow;
00333 }

UInt_t ScintCalTimePeriod::TimePeriod (  )  const [virtual]

Definition at line 336 of file ScintCalTimePeriod.cxx.

References ftimePeriod.

Referenced by ScintCalDatabase::InfoObjectUpdate(), and WriteToMINOSDbi().

00337 {
00338   return ftimePeriod;
00339 }

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

Definition at line 414 of file ScintCalTimePeriod.cxx.

References VldTimeStamp::Add(), VldTimeStamp::AsString(), DbiWriter< T >::Close(), Munits::day, CalDrift::GetMedianAsR1_18_2(), CalDrift::GetMedianErrAsR1_18_2(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), VldTimeStamp::GetSec(), DbiWriter< T >::IsOpen(), SimFlag::kData, kFar, kNear, Dbi::kTableMissing, n, VldTimeStamp::Print(), and CalDrift::SetRecoVersion().

00416                                                          {
00417   
00418   std::cout << "(nsmayer) Starting WriteToMINOSDbi " << std::endl;
00419   int nsm_count=0;
00420   
00421   nsm_count=1;
00422   std::cout << "(nsmayer) " << nsm_count << std::endl;
00423   int trDet;
00424   
00425   if (DetectorType::kFar == this->Detector()){
00426     cout << "Far detector" << endl;
00427     trDet = DetectorType::kFar;
00428   }
00429   else{
00430     if (DetectorType::kNear == this->Detector()){
00431       cout << "Near detector" << endl;
00432       trDet = DetectorType::kNear;
00433     }
00434     else{
00435       cout << "Unknown detector" << endl;
00436       trDet = -100;
00437     }
00438   }
00439 
00440   nsm_count=2;
00441   std::cout << "(nsmayer) " << nsm_count << std::endl;
00442   
00443   //Gemma
00444   VldTimeStamp comparetime(year,month,day,0,0,0); //primo giorno da considerare
00445   VldTimeStamp endtime(year,month,day,0,0,0); //giorno da escludere
00446   Double_t interval = 1*Munits::day;
00447   endtime.Add(VldTimeStamp((int)interval,0)); 
00448   VldTimeStamp weekbefore(year,month,day,0,0,0);
00449   weekbefore.Add(VldTimeStamp(-7*(int)interval,0)); 
00450 
00451   nsm_count=3;
00452   std::cout << "(nsmayer) " << nsm_count << std::endl;
00453 
00454   //Get the start time of this object
00455   Double_t startSecond = ((Double_t) TimePeriod())*(Length());
00456   VldTimeStamp start(startSecond);
00457   start.Print();
00458   
00459   nsm_count=4;
00460   std::cout << "(nsmayer) " << nsm_count << std::endl;
00461   
00462   if (start.GetSec() < comparetime.GetSec()){
00463     
00464     nsm_count=5;
00465     std::cout << "(nsmayer) " << nsm_count << std::endl;
00466 
00467     cout << "passo di qui" << endl;
00468     return;
00469   }
00470   //Gemma  
00471   if (start.GetSec() >= endtime.GetSec()){
00472 
00473     nsm_count=6;
00474     std::cout << "(nsmayer) " << nsm_count << std::endl;
00475     
00476     cout<<"passo da qua"<<endl;
00477     return;
00478   }
00479   
00480   nsm_count=7;
00481   std::cout << "(nsmayer) " << nsm_count << std::endl;
00482 
00483   cout << "Starttime " << start.AsString() << endl;
00484   
00485   cout<<"******************"<<Median()<<"    "<<SigOvRtN()<<"    "<<
00486     BackMedian()<<"  "<<BackMedianErr()<<"     "<<
00487     FrontMedian()<<"    "<<FrontMedianErr()<<endl;
00488   
00489   //NEW: PUT LIMITATIONS ON THE CONSTANTS I PUT IN DB
00490   //open tmpFile and write constants
00491   FILE * tmpFile;
00492 
00493   nsm_count=8;
00494   std::cout << "(nsmayer) " << nsm_count << std::endl;
00495 
00496   tmpFile=fopen("/minos/data/users/nsmayer/tmp/tmpFile","w");
00497  
00498   fprintf(tmpFile,"median %f mean %f  error %f nMuons %d \n",
00499           Median(),Mean(),SigOvRtN(),NumMuons() );
00500   cout<< Median()<<"   "<<Mean()<<"   "<<SigOvRtN()<<"   "<<NumMuons() <<endl; 
00501   //put checks on value here
00502 
00503   FILE *tmpDatFile=fopen("/minos/data/users/nsmayer/tmp/tmpDatFile", "w");
00504   fprintf( tmpDatFile, "%f \n %f \n %f \n %d \n", Median(),Mean(),SigOvRtN(),NumMuons() );
00505 
00506   
00507   TFile *fTree = new TFile("/minos/data/users/nsmayer/tmp/DataTreeFile.root", "update");
00508   fTree->cd();
00509   TTree *driftTree = new TTree("drift", "drift");
00510   double trMedian = Median();
00511   double trMean = Mean();
00512   double trSigOvRtN = SigOvRtN();
00513   double trNumMuons = NumMuons();
00514   driftTree->Branch("detector", &detector, "detector/I");
00515   driftTree->Branch("Median", &trMedian, "Median/D");
00516   driftTree->Branch("Mean", &trMean, "Mean/D");
00517   driftTree->Branch("SigOvRtN", &trSigOvRtN, "SigOvRtN/D");
00518   driftTree->Branch("NumMuons", &trNumMuons, "NumMuons/D");
00519   driftTree->Branch("year", &year, "year/I");
00520   driftTree->Branch("month", &month, "month/I");
00521   driftTree->Branch("day", &day, "day/I");
00522   driftTree->Fill();
00523   driftTree->Write();
00524   fTree->Close();
00525   
00526 
00527   nsm_count=9;
00528   std::cout << "(nsmayer) " << nsm_count << std::endl;
00529 
00530   if(DetectorType::kFar ==detector){
00531     if(NumMuons()>22000){
00532       fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00533       return;
00534     }
00535   } //FD
00536   else if(DetectorType::kNear ==detector){
00537     if(NumMuons()>45000){  //with Dogwood the prescaling is 1:16
00538       fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00539       return;
00540     }
00541   } //ND
00542 
00543   nsm_count=10;
00544   std::cout << "(nsmayer) " << nsm_count << std::endl;
00545 
00546   //to check the constant I am writing is fine, 
00547   //read constants from database for the week before, 
00548   //linearly interpolate if there are 2 points and compare prediction to measurement
00549   //if it is withing 2 sigma, take point
00550   //start.GetSec()
00551 
00552   nsm_count=11;
00553   std::cout << "(nsmayer) " << nsm_count << std::endl;
00554 
00555   Dbi::Task task = 1; //default setting is dogwood task
00556   VldTimeStamp ts(weekbefore);
00557   TGraphErrors grpoints;
00558   
00559   nsm_count=12;
00560   std::cout << "(nsmayer) " << nsm_count << std::endl;
00561   
00562   for(; ts<=start; ts.Add(VldTimeStamp((int)interval,0))) {
00563     VldContext fd(detector, SimFlag::kData, ts);
00564     DbiResultPtr<CalDrift> fdtsTable("CALDRIFT",
00565                                      fd,task,
00566                                      Dbi::kTableMissing,
00567                                      false);
00568     if (fdtsTable.GetNumRows()){
00569       const CalDrift* fdtsRow = fdtsTable.GetRow(0);
00570       int n=grpoints.GetN();
00571       grpoints.SetPoint(n,(Double_t)ts,fdtsRow->GetMedianAsR1_18_2(detector));
00572       grpoints.SetPointError(n,0.,fdtsRow->GetMedianErrAsR1_18_2(detector));
00573     }
00574   } //loop over a week
00575 
00576   nsm_count=13;
00577   std::cout << "(nsmayer) " << nsm_count << std::endl;
00578 
00579   //Make the table row
00580   CalDrift row = TableRow();
00581   row.SetRecoVersion(recoversion.c_str());
00582 
00583   nsm_count=14;
00584   std::cout << "(nsmayer) " << nsm_count << std::endl;
00585 
00586   if(grpoints.GetN()>=2){
00587     TF1* retta=new TF1("retta","[0]+[1]*x");
00588     grpoints.Fit("retta");
00589     double y_end=retta->GetParameter(0)+retta->GetParameter(1)*(double)start; 
00590     cout<<"For debugging purposes check expected median with evaluated median: "
00591         <<y_end <<"    "<<row.GetMedianAsR1_18_2(detector) <<endl; 
00592    if(fabs(row.GetMedianAsR1_18_2(detector)-y_end)>
00593        2.*row.GetMedianErrAsR1_18_2(detector)){
00594       fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00595       return;
00596     }
00597   }
00598 
00599   nsm_count=15;
00600   std::cout << "(nsmayer) " << nsm_count << std::endl;
00601 
00602   //to implement again, wrong how they are now   
00603   /*
00604     //check versus reference median of 01/12/2005
00605    //still fd at this moment
00606     Double_t median=MedianAsR1_18_2(detector,Median(),recoversion);
00607     if( (( (median-478.55)/478.55*100.)>5.) || 
00608     ( ((median-478.55)/478.55*100.)<-5.)){
00609     fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00610     return;
00611     }
00612     if((SigOvRtN()/478.55*100.)>1.){
00613     fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00614     return;   
00615     }
00616     Double_t mean=MeanAsR1_18_2(detector,Mean(),recoversion);
00617     if( ( ((mean-671.334)/671.334)>6.) ||
00618         ( ((mean-671.334)/671.334*100.)<-6.)){
00619       fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00620       return;
00621     } 
00622   } //FD
00623   else if(DetectorType::kNear ==detector){
00624       //check versus reference median of 01/12/2005
00625     Double_t median=MedianAsR1_18_2(detector,Median(),recoversion);
00626     cout<<"median come  R1_18_2  "<<median<<endl;
00627     if( ( ((median-495.05)/495.05*100.)>1.) ||
00628         ( ((median-495.05)/495.05*100.)<-8.)){
00629       fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00630       return;
00631     }
00632     if((SigOvRtN()/495.05*100.)>1.){
00633       fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00634       return;   
00635     }
00636     Double_t mean=MeanAsR1_18_2(detector,Mean(),recoversion);
00637     if( ( ((mean-637.794)/637.794*100.)>1.) ||
00638         ( ((mean-637.794)/637.794*100.)<-8.5)){
00639       fprintf(tmpFile,"Prevent from putting odd constant in db: check! \n");
00640       return;
00641     }
00642   } //ND
00643   */
00644 
00645   nsm_count=16;
00646   std::cout << "(nsmayer) " << nsm_count << std::endl;
00647 
00648   fclose(tmpFile);
00649   fclose(tmpDatFile);
00650 
00651   //Set this object's expiry time
00652   time_t vcSec = start.GetSec() + 24*60*60 + /*1*/0;   // Ends a day later
00653   VldTimeStamp    end(vcSec,0);
00654   // Construct the VldRange.
00655   VldRange      range(detector, 
00656                       5, //SimFlag::kData + SimFlag::kMC
00657                       start,
00658                       end,
00659                       "ScintCal");
00660   Int_t aggNo = -1;
00661   // Decide a creation date (Increment by 1 second on each attempt)
00662   time_t vcSec2 = start.GetSec() + 0;
00663   VldTimeStamp create(vcSec2,0);
00664   
00665   DbiWriter<CalDrift> writer(range,
00666                              aggNo,
00667                              task,
00668                              create,
00669                              0,
00670                              "New Dogwood database",
00671                              "CALDRIFT");
00672  
00673   cout << "Created a DbiWriter object" << endl;
00674 
00675   if (!writer.IsOpen()) {
00676     cout << "Writer not open - aborting" << endl; 
00677     return;
00678   }
00679   
00680   //Add by Gemma to make sure constats are written right
00681   // even if not in cronoligical order
00682   //writer.SetOverlayCreationDate();
00683   
00684   //I'll put oon top because i need to use median and apply right recoversion immediately
00685   //Make the table row
00686   //CalDrift row = TableRow();
00687   // row.SetRecoVersion(recoversion.c_str());
00688   
00689   //Write the row into the database
00690   writer << row;
00691   
00692   //writer.Abort();   cout << "WARNING !! Unexpected number of channels writer.abort() called\n";
00693   writer.Close();  cout << "Completed " << endl;
00694 }

void ScintCalTimePeriod::WriteToMINOSDbi (  )  [virtual]

Definition at line 342 of file ScintCalTimePeriod.cxx.

References VldTimeStamp::AsString(), DbiWriter< T >::Close(), Detector(), VldTimeStamp::GetSec(), DbiWriter< T >::IsOpen(), kFar, kNear, Length(), CalDrift::SetRecoVersion(), TableRow(), and TimePeriod().

00343 {
00344   if (DetectorType::kFar == this->Detector()){
00345     cout << "Far detector" << endl;
00346   }
00347   else{
00348     if (DetectorType::kNear == this->Detector()){
00349       cout << "Far detector" << endl;
00350     }
00351     else{
00352       cout << "Unknown detector" << endl;
00353     }
00354   }
00355 
00356   //originale di justin
00357   //VldTimeStamp comparetime(2006,02,01,0,0,0);
00358   //Gemma
00359   VldTimeStamp comparetime(2009,2,2,0,0,0); //primo giorno da considerare
00360   VldTimeStamp endtime(2009,3,6,0,0,0); //giorno da escludere
00361 
00362   //Get the start time of this object
00363   Double_t startSecond = ((Double_t) TimePeriod())*(Length());
00364   VldTimeStamp start(startSecond);
00365   if (start.GetSec() < comparetime.GetSec()){return;}
00366   //Gemma  
00367   if (start.GetSec() >= endtime.GetSec()){return;}
00368   
00369   cout << "Starttime " << start.AsString() << endl;
00370   
00371   //Set this object's expiry time
00372   time_t vcSec = start.GetSec() + 24*60*60 + 0;   // Ends a day later
00373   VldTimeStamp    end(vcSec,0);
00374   // Construct the VldRange.
00375   VldRange      range(DetectorType::kNear,//this->Detector()
00376                       5, //SimFlag::kData + SimFlag::kMC
00377                       start,
00378                       end,
00379                       "ScintCal");
00380   Int_t aggNo = -1;
00381   Dbi::Task task = 1; //default setting is dogwood task
00382   // Decide a creation date (Increment by 1 second on each attempt)
00383   time_t vcSec2 = start.GetSec() + 0;
00384   VldTimeStamp create(vcSec2,0);
00385   
00386   DbiWriter<CalDrift> writer(range,
00387                              aggNo,
00388                              task,
00389                              create,
00390                              0,
00391                              "New Dogwood database",
00392                              "CALDRIFT");
00393  
00394   cout << "Created a DbiWriter object" << endl;
00395 
00396   if (!writer.IsOpen()) {
00397          cout << "Writer not open - aborting" << endl; 
00398          return;
00399   }
00400   
00401 
00402   //Make the table row
00403   CalDrift row = TableRow();
00404   row.SetRecoVersion("Dogwood");
00405   //Write the row into the database
00406   writer << row;
00407   
00408   //writer.Abort();   cout << "WARNING !! Unexpected number of channels writer.abort() called\n";
00409   writer.Close();  cout << "Completed " << endl;
00410 }


Member Data Documentation

DetectorType::Detector_t ScintCalTimePeriod::fdetector [private]

Definition at line 55 of file ScintCalTimePeriod.h.

Referenced by Detector(), operator+(), operator=(), and SingleHitUpdate().

Double_t ScintCalTimePeriod::flength [private]

Definition at line 56 of file ScintCalTimePeriod.h.

Referenced by Length(), operator+(), operator=(), and SetBinLength().

Definition at line 57 of file ScintCalTimePeriod.h.

Referenced by operator+(), operator=(), SetTimePeriod(), and TimePeriod().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1