]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliDBPPR.cxx
Updated Linkdef and libTOF.pkg
[u/mrichter/AliRoot.git] / PHOS / AliDBPPR.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15  
16 /* $Id$ */
17  
18 //_________________________________________________________________________
19 // DB Class for table PPR:
20 //
21 //*-- Author: Yves Schutz (SUBATECH)
22 //////////////////////////////////////////////////////////////////////////////
23  
24 #include <stdlib.h> 
25 #include <iostream.h> 
26  
27 // --- ROOT system ---
28 #include "TSQLServer.h" 
29 #include "TSQLRow.h" 
30 #include "TSQLResult.h" 
31 #include "TDatime.h" 
32  
33 // --- Standard library ---
34  
35 // --- AliRoot header files ---  
36 #include "AliDBPPR.h" 
37  
38 ClassImp(AliDBPPR)
39 //____________________________________________________________________________
40 AliDBPPR::AliDBPPR()
41 {   
42   fCurrentEntry = 1 ; // first valid entry (0 = labels)
43   fNfields = 6 ;
44   fFields = new TString[6]; 
45   fFields[0] = "RUN"; 
46   fFields[1] = "EVENT"; 
47   fFields[2] = "DATE"; 
48   fFields[3] = "SIMULATION"; 
49   fFields[4] = "DIGITIZATION"; 
50   fFields[5] = "RECONSTRUCTION"; 
51 }   
52 //____________________________________________________________________________
53 AliDBPPR::~AliDBPPR()
54 {   
55   delete[] fFields ;
56 }   
57 //____________________________________________________________________________
58 void AliDBPPR::GetEntry(Option_t * opt)
59 {   
60    // Retrieves one single row from the table   //  opt = first : retrieves first entry 
61    //  opt = last  : retrieves last entry 
62    //  opt = next  : retrieves next to current entry 
63   TSQLServer * mysql = TSQLServer::Connect("mysql://ccmysql.in2p3.fr:3306/alice", "schutz", "po2hgwy") ;
64   TSQLResult * result = mysql->Query("SELECT * FROM PPR") ; 
65   Int_t count = result->GetRowCount() ; 
66   if ( !strcmp(opt, "first") ) fCurrentEntry = 1 ; 
67   if ( !strcmp(opt, "last") ) fCurrentEntry = count ; 
68   if ( fCurrentEntry > count ) fCurrentEntry = 1 ; 
69   Int_t i; 
70   Int_t end = fCurrentEntry ; 
71   TSQLRow * row = 0 ; 
72   for ( i = 0 ; i < end ; i++ ) {
73      fCurrentEntry++ ; 
74     row = result->Next() ; 
75   }   
76     fRUN = atoi(row->GetField(0)) ; 
77     fEVENT = atoi(row->GetField(1)) ; 
78     fDATE = TDatime(row->GetField(2)) ; 
79     fSIMULATION = row->GetField(3) ; 
80     fDIGITIZATION = row->GetField(4) ; 
81     fRECONSTRUCTION = row->GetField(5) ; 
82 }