/[PAMELA software]/PamelaDigitizer/Pamelagp2Digits.cxx
ViewVC logotype

Diff of /PamelaDigitizer/Pamelagp2Digits.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by silvio, Thu Sep 13 11:00:53 2007 UTC revision 1.13 by mocchiut, Tue Aug 11 14:56:31 2009 UTC
# Line 4  Line 4 
4  //      The conversion is done using a slightly patched version of  //      The conversion is done using a slightly patched version of
5  //      Rene Brun's h2root.  //      Rene Brun's h2root.
6  //  //
7  //      Created : Jan Conrad (conrad@particle.kth.se)  //      Created : 2006 Jan Conrad  (conrad@particle.kth.se)
8  //      Modified: Silvio Orsi (silvio.orsi@roma2.infn.it)  //      Modified: 2007 Silvio Orsi (silvio.orsi@roma2.infn.it)
9  //  //
10  //  //
11  //  HOWTO (RECOMMENDED):  //  HOWTO (RECOMMENDED):
12  //  ./ Pamelagp2Digits filename.his  //  ./ Pamelagp2Digits filename.his
13  //  It generates filename.pam (PAMELA raw data) and filename.gp.root (sim info)  //  It generates filename.pam (PAMELA raw data) and filename.gp.root (sim info)
14  //    //  
15  //  HOWTO (EXPERT, only for testing purposes)  //  NB: more details are present in the file HOW-TO-DIGIT.TXT
16    //
17    //  HOWTO (only for testing purposes)
18  //  Pamelagp2Digits hbook_filename root_filename  raw_filename compress tolower  //  Pamelagp2Digits hbook_filename root_filename  raw_filename compress tolower
19  //  - If the 2nd and 3rd parameters are missing the names are generated from the hbook file name.  //  - If the 2nd and 3rd parameters are missing the names are generated from the hbook file name.
20  //  - The following flags are from h2root and default values are used:  //  - The following flags are from h2root and default values are used:
# Line 24  Line 26 
26  //                convertex to lower case  //                convertex to lower case
27  //  //
28  //  MODIFICATIONS:  //  MODIFICATIONS:
29  //  v. 1.0 (S.Orsi, September 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
31    //
32    //  v. 1.4 (S.Orsi, Roma2, 11 October 2007)
33    //  - similar to v. 1.3
34    //
35    //  v. 1.3 (S.Orsi, Roma2, 11 October 2007)
36    //  - TOF: + changes and major corrections in ADC and TDC (W.Menn, D.Campana, S.Orsi)
37    //         + flag DEBUG added (default: DEBUG=false; if true, print on screem some messages to debug)
38    //  - AC: + shift register filled;
39    //        + minor bugs fixed
40    //        + counters increment by 1 at each event (they were constant before)
41    //  - S4: + minor bugs fixed (S.Borisov)
42    //        + the routine DigitizeS4() is now inserted in the code. For DV versions earlier than October 2007, the option "-S4" is still needed because S4 calibration is not present
43    //  - corrected severe bug that caused yoda to process only part of large data files (file.pam). S4 data were written to file even if the DigitizeS4() routine was not called. Previous versions of the digitizer should have crashed always, but unexpectedly worked on small files.
44    //  - 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. The file is included only from release 1.5
45    //  - digitizer version numbers modified according to CVS repository (v1.00->v1.1, v1.01->v1.2)
46    //  - some flags (LDFLAGS) in the Makefile have been changed; they are needed on some machines (e.g. pamelatov.roma2.infn.it), but give errors on others (e.g. pamelaws02.na.infn.it). See Makefile for details if the compilation fails due to library errors)
47    //
48    //  v. 1.2 (S.Orsi, Roma2, 28 September 2007)
49    //  - TOF TDC inserted (to be tuned)
50    //  - improved tracker dEdx, tracker saturation inserted (S.Bottai)
51    //  - S4 routine inserted in code (not in read-out)
52    //  - bugs with packet length corrected
53    //  - small bugs fixed
54    //  - NB: Run DarthVader with the options: "DarthVader -zerofill -idRun 1 -ALL +RUN +CAL [ --no-crosstalk ] +TRK +TOF +AC +TRG +ND" or  "DarthVader -zerofill -idRun 1 +CAL [ --no-crosstalk ] -S4", i.e. without S4
55    //
56    //  v. 1.1 (S.Orsi, Roma2, 13 September 2007)
57  //  - trigger (dummy), tof (preliminary, adc only), ND (preliminary) inserted  //  - trigger (dummy), tof (preliminary, adc only), ND (preliminary) inserted
58  //  - various changes and bug fixes  //  - various changes and bug fixes
59  //  - padding increased (fPADbuffer=64, fPadding = padbytes+64)  //  - padding increased (fPADbuffer=64, fPadding = padbytes+64)
60  //  //
61  //  v. beta (J.Conrad)  //  v. beta (J.Conrad, KTH, 2006)
62  //  - compiles; includes pscu, calo, trk, ac  //  - compiles; includes pscu, calo, trk, ac; not present on cvs
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  int Error;   //to be removed soon  using namespace std;
69    
70    //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
73    
# Line 246  Int_t golower  = 1; Line 264  Int_t golower  = 1;
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");
# Line 267  int main(int argc, char **argv) Line 288  int main(int argc, char **argv)
288    void *qq = iq;    void *qq = iq;
289     q = (float*)qq;     q = (float*)qq;
290    char *file_in=argv[1];    char *file_in=argv[1];
291    char *file_out = " ";    char *file_out = new char[512];
292      strcpy(file_out," ");
293    char *file_raw;    char *file_raw;
294    
295    Int_t compress = 1;    Int_t compress = 1;
# Line 498  void convert_directory(const char *dir, Line 520  void convert_directory(const char *dir,
520    }    }
521    h1->SetEntries(nentries);    h1->SetEntries(nentries);
522    h1->Write();    h1->Write();
523    delete h1;    //  delete h1;
524      h1->Delete();
525  }  }
526  //____________________________________________________________________________  //____________________________________________________________________________
527    void convert_cwn(Int_t id,char* file_raw)    void convert_cwn(Int_t id,char* file_raw)
# Line 786  void convert_directory(const char *dir, Line 809  void convert_directory(const char *dir,
809    
810    tree->Write();    tree->Write();
811    
812    std::cout << "Invoking Digitizer" << endl << flush;    cout << "Invoking Digitizer" << endl << flush;
813      const char *ndl[8];
814    Digitizer* dig = new Digitizer(tree,file_raw);    char *q,*q1;
815      q=(char*)malloc(5 *sizeof(char));
816      q1=(char*)malloc(5 *sizeof(char));
817      ndl[0]="nspe";
818      ndl[1]="ntof";
819      ndl[2]="ncat";
820      ndl[3]="ncas";
821      ndl[4]="ncar";
822      ndl[5]="ncal";
823      ndl[6]="nndd";
824      ndl[7]="nstr";
825    
826      int nspe=200,ntof=200,ncat=50,ncas=50,ncar=100,ncal=1000,nnd=200,nstr=1000,par[8],tmp=0,t;
827      par[0]=nspe;
828      par[1]=ntof;
829      par[2]=ncat;
830      par[3]=ncas;
831      par[4]=ncar;
832      par[5]=ncal;
833      par[6]=nnd;
834      par[7]=nstr;
835    
836      ifstream np("vectpar.dat",ios::in);
837      if(!np)printf("ATTENTION: Using default vector legths!\n");
838      else{
839        while(!np.eof()){
840          np>>q>>tmp;
841          if(np.eof())break;
842          if(tmp<=0){
843            cout<<"ATTENTION: Length of one vector is negative or equal 0!"<<endl<<q<<"="<<tmp<<endl;
844            break;
845          }
846          t=0;
847          while(tmp){
848            strcpy(q1,ndl[t]);
849            if(q[0]==q1[0] && q[1]==q1[1] && q[2]==q1[2] && q[3]==q1[3]){
850              par[t]=tmp;
851              tmp=0;
852              cout<<q<<" "<<par[t]<<"["<<t<<"]"<<endl;
853            }
854            t++;
855          }
856        }
857        nspe=par[0];
858        ntof=par[1];
859        ncat=par[2];
860        ncas=par[3];
861        ncar=par[4];
862        ncal=par[5];
863        nnd=par[6];
864        nstr=par[7];
865      }
866      Digitizer* dig = new Digitizer(tree,file_raw,nspe,ntof,ncat,ncas,ncar,ncal,nnd,nstr);
867    dig->Loop();    dig->Loop();
868    dig->Close();    dig->Close();
869    
870    std::cout << "Finished" << endl << flush;    cout << "Finished" << endl;
871    
872  }  }
873    

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23