| 26 | 
 //                convertex to lower case | 
 //                convertex to lower case | 
| 27 | 
 // | 
 // | 
| 28 | 
 //  MODIFICATIONS: | 
 //  MODIFICATIONS: | 
 | 
 // | 
  | 
 | 
 //  v. 1.6 (S.Orsi, Roma2, 31 October 2007) | 
  | 
 | 
 //  - TOF: (Campana, Menn, Orsi) | 
  | 
 | 
 //         + bugs fixed | 
  | 
 | 
 //         + crc included | 
  | 
 | 
 //         + introduction of 3 control bits in the ADC and TDC words before writing fDataTof | 
  | 
 | 
 //         + channel map corrected (correspondence between PMT# and TDC channel) | 
  | 
 | 
 //         + new conversion pC to ADC | 
  | 
 | 
 //         + scaling factors to tune MC data to real ones | 
  | 
 | 
 //  - HOW-TO-DIGIT.TXT file updated (E.Vannuccini) | 
  | 
 | 
 // | 
  | 
| 29 | 
 //  v. 1.5 (S.Orsi, Roma2, 11 October 2007) | 
 //  v. 1.5 (S.Orsi, Roma2, 11 October 2007) | 
| 30 | 
 //  - file HOW-TO-DIGIT.TXT written (mainly by S.Bottai): contains information on how to run the chain from the DB creation to DarthVader through Digitizer, yoda and YodaProfiler | 
 //  - file HOW-TO-DIGIT.TXT written (mainly by S.Bottai): contains information on how to run the chain from the DB creation to DarthVader through Digitizer, yoda and YodaProfiler | 
| 31 | 
 // | 
 // | 
| 63 | 
 // | 
 // | 
| 64 | 
 ///////////////////////////////////////////////////////////////////////// | 
 ///////////////////////////////////////////////////////////////////////// | 
| 65 | 
  | 
  | 
 | 
 #include <stdlib.h> | 
  | 
 | 
 #include <string.h> | 
  | 
 | 
 #include <ctype.h> | 
  | 
 | 
 #include "Riostream.h" | 
  | 
 | 
 #include "TFile.h" | 
  | 
 | 
 #include "TDirectory.h" | 
  | 
 | 
 #include "TTree.h" | 
  | 
 | 
 #include "TLeafI.h" | 
  | 
 | 
 #include "TH1.h" | 
  | 
 | 
 #include "TH2.h" | 
  | 
 | 
 #include "TProfile.h" | 
  | 
 | 
 #include "TGraph.h" | 
  | 
 | 
 #include "TMath.h" | 
  | 
| 66 | 
 #include "Digitizer.h" | 
 #include "Digitizer.h" | 
| 67 | 
  | 
  | 
| 68 | 
  | 
 using namespace std; | 
| 69 | 
  | 
  | 
| 70 | 
 int Error;   //to be removed soon | 
 int Error;   //to be removed soon | 
| 71 | 
  | 
  | 
| 72 | 
 //  Define the names of the Fortran common blocks for the different OSs | 
 //  Define the names of the Fortran common blocks for the different OSs | 
| 264 | 
 Int_t bufsize  = 64000; | 
 Int_t bufsize  = 64000; | 
| 265 | 
 Int_t optcwn = 1; | 
 Int_t optcwn = 1; | 
| 266 | 
  | 
  | 
| 267 | 
  | 
 char *DigitizerInfo(bool print); | 
| 268 | 
  | 
  | 
| 269 | 
 int main(int argc, char **argv) | 
 int main(int argc, char **argv) | 
| 270 | 
  | 
  | 
| 271 | 
 { | 
 { | 
| 272 | 
  | 
   char* cha=DigitizerInfo(1); | 
| 273 | 
  | 
  | 
| 274 | 
   if (argc < 2) { | 
   if (argc < 2) { | 
| 275 | 
      printf("Error: Pamelagp2Digits \n"); | 
      printf("Error: Pamelagp2Digits \n"); | 
| 276 | 
      printf("Pamelagp2Digits file.hbook file.root file.pam [compress] [tolower] [lrecl] [bufsize] [optcwn] \n"); | 
      printf("Pamelagp2Digits file.hbook file.root file.pam [compress] [tolower] [lrecl] [bufsize] [optcwn] \n"); | 
| 519 | 
   } | 
   } | 
| 520 | 
   h1->SetEntries(nentries); | 
   h1->SetEntries(nentries); | 
| 521 | 
   h1->Write(); | 
   h1->Write(); | 
| 522 | 
   delete h1; | 
   //  delete h1; | 
| 523 | 
  | 
   h1->Delete(); | 
| 524 | 
 } | 
 } | 
| 525 | 
 //____________________________________________________________________________ | 
 //____________________________________________________________________________ | 
| 526 | 
   void convert_cwn(Int_t id,char* file_raw) | 
   void convert_cwn(Int_t id,char* file_raw) | 
| 808 | 
  | 
  | 
| 809 | 
   tree->Write(); | 
   tree->Write(); | 
| 810 | 
  | 
  | 
| 811 | 
   std::cout << "Invoking Digitizer" << endl << flush; | 
   cout << "Invoking Digitizer" << endl << flush; | 
| 812 | 
  | 
   char *ndl[8],*q,*q1; | 
| 813 | 
   Digitizer* dig = new Digitizer(tree,file_raw); | 
   q=(char*)malloc(5 *sizeof(char)); | 
| 814 | 
  | 
   q1=(char*)malloc(5 *sizeof(char)); | 
| 815 | 
  | 
   ndl[0]="nspe"; | 
| 816 | 
  | 
   ndl[1]="ntof"; | 
| 817 | 
  | 
   ndl[2]="ncat"; | 
| 818 | 
  | 
   ndl[3]="ncas"; | 
| 819 | 
  | 
   ndl[4]="ncar"; | 
| 820 | 
  | 
   ndl[5]="ncal"; | 
| 821 | 
  | 
   ndl[6]="nndd"; | 
| 822 | 
  | 
   ndl[7]="nstr"; | 
| 823 | 
  | 
  | 
| 824 | 
  | 
   int nspe=200,ntof=200,ncat=50,ncas=50,ncar=100,ncal=1000,nnd=200,nstr=1000,par[8],tmp=0,t; | 
| 825 | 
  | 
   par[0]=nspe; | 
| 826 | 
  | 
   par[1]=ntof; | 
| 827 | 
  | 
   par[2]=ncat; | 
| 828 | 
  | 
   par[3]=ncas; | 
| 829 | 
  | 
   par[4]=ncar; | 
| 830 | 
  | 
   par[5]=ncal; | 
| 831 | 
  | 
   par[6]=nnd; | 
| 832 | 
  | 
   par[7]=nstr; | 
| 833 | 
  | 
  | 
| 834 | 
  | 
   ifstream np("vectpar.dat",ios::in); | 
| 835 | 
  | 
   if(!np)printf("ATTENTION: Using default vector legths!\n"); | 
| 836 | 
  | 
   else{ | 
| 837 | 
  | 
     while(!np.eof()){ | 
| 838 | 
  | 
       np>>q>>tmp; | 
| 839 | 
  | 
       if(np.eof())break; | 
| 840 | 
  | 
       if(tmp<=0){ | 
| 841 | 
  | 
         cout<<"ATTENTION: Length of one vector is negative or equal 0!"<<endl<<q<<"="<<tmp<<endl; | 
| 842 | 
  | 
         break; | 
| 843 | 
  | 
       } | 
| 844 | 
  | 
       t=0; | 
| 845 | 
  | 
       while(tmp){ | 
| 846 | 
  | 
         q1=ndl[t]; | 
| 847 | 
  | 
         if(q[0]==q1[0] && q[1]==q1[1] && q[2]==q1[2] && q[3]==q1[3]){ | 
| 848 | 
  | 
           par[t]=tmp; | 
| 849 | 
  | 
           tmp=0; | 
| 850 | 
  | 
           cout<<q<<" "<<par[t]<<"["<<t<<"]"<<endl; | 
| 851 | 
  | 
         } | 
| 852 | 
  | 
         t++; | 
| 853 | 
  | 
       } | 
| 854 | 
  | 
     } | 
| 855 | 
  | 
     nspe=par[0]; | 
| 856 | 
  | 
     ntof=par[1]; | 
| 857 | 
  | 
     ncat=par[2]; | 
| 858 | 
  | 
     ncas=par[3]; | 
| 859 | 
  | 
     ncar=par[4]; | 
| 860 | 
  | 
     ncal=par[5]; | 
| 861 | 
  | 
     nnd=par[6]; | 
| 862 | 
  | 
     nstr=par[7]; | 
| 863 | 
  | 
   } | 
| 864 | 
  | 
   Digitizer* dig = new Digitizer(tree,file_raw,nspe,ntof,ncat,ncas,ncar,ncal,nnd,nstr); | 
| 865 | 
   dig->Loop(); | 
   dig->Loop(); | 
| 866 | 
   dig->Close(); | 
   dig->Close(); | 
| 867 | 
  | 
  | 
| 868 | 
   std::cout << "Finished" << endl << flush; | 
   cout << "Finished" << endl; | 
| 869 | 
  | 
  | 
| 870 | 
 } | 
 } | 
| 871 | 
  | 
  |