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

Diff of /PamelaDigitizer/Digitizer.cxx

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

revision 1.5 by silvio, Wed Nov 28 18:54:31 2007 UTC revision 1.6 by silvio, Wed Dec 5 13:02:50 2007 UTC
# Line 18  Line 18 
18  #include "TLeafI.h"  #include "TLeafI.h"
19  #include "TH1.h"  #include "TH1.h"
20  #include "TH2.h"  #include "TH2.h"
21    #include "TF1.h"
22  #include "TMath.h"  #include "TMath.h"
23  #include "TRandom.h"  #include "TRandom.h"
24  #include "TSQLServer.h"  #include "TSQLServer.h"
# Line 40  Digitizer::Digitizer(TTree* tree, char* Line 41  Digitizer::Digitizer(TTree* tree, char*
41    fhBookTree = tree;    fhBookTree = tree;
42    fFilename =  file_raw;    fFilename =  file_raw;
43    fCounter = 0;    fCounter = 0;
44      fCounterPhys = 0; // SO 5/12/'07
45    fOBT = 0;    fOBT = 0;
46    
47    //    //
# Line 229  void Digitizer::Loop() { Line 231  void Digitizer::Loop() {
231        
232    DigitizeTrackCalib(1);    DigitizeTrackCalib(1);
233    UInt_t length=fTracklength*2;    UInt_t length=fTracklength*2;
234    DigitizePSCU(length,0x12);    DigitizePSCU(length,0x12,fDataPSCU);
235    AddPadding();    AddPadding();
236    WriteTrackCalib();    WriteTrackCalib();
237        
238    DigitizeTrackCalib(2);    DigitizeTrackCalib(2);
239    length=fTracklength*2;    length=fTracklength*2;
240    DigitizePSCU(length,0x13);    DigitizePSCU(length,0x13,fDataPSCU);
241    AddPadding();    AddPadding();
242    WriteTrackCalib();    WriteTrackCalib();
243      
244      DigitizeRunHeader();
245      WriteRunHeader();
246    
247    LoadMipCor();  // some initialization of parameters -not used now-    LoadMipCor();  // some initialization of parameters -not used now-
248    //  end loading, digitizing and writing tracker calibration    //  end loading, digitizing and writing tracker calibration
249    
# Line 253  void Digitizer::Loop() { Line 258  void Digitizer::Loop() {
258      nbytes += fhBookTree->GetEntry(i);      nbytes += fhBookTree->GetEntry(i);
259      // read detectors sequentially:      // read detectors sequentially:
260      // http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf      // http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf
261      // on pamelatov:      // on pamelatov: /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp
262      // /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp      //DigitizeTRIGGER();
     DigitizeTRIGGER();  
263      DigitizeTOF();      DigitizeTOF();
264      DigitizeAC();      DigitizeAC();
265      DigitizeCALO();      DigitizeCALO();
266      DigitizeTrack();      DigitizeTrack();
267      DigitizeS4();      DigitizeS4();
268      DigitizeND();      DigitizeND();
269        //      //
270      // Add padding to 64 bits      // Add padding to 64 bits
271      //      //
272      AddPadding();      AddPadding();
273  //      //
274      // Create CPU header, we need packet type (0x10 = physics data) and packet length.      // Create CPU header, we need packet type (0x10 = physics data) and packet length.
275      //      //
276      UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;      UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;
277      //UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;      //UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer;
278      DigitizePSCU(length,0x10);      DigitizePSCU(length,0x10,fDataPSCU);
279      if ( !i%100 ) std::cout << "writing event " << i << endl;      if ( !i%100 ) std::cout << "writing event " << i << endl;
280      WriteData();      WriteData();
281    };    };
282    
283      DigitizeRunTrailer();
284      WriteRunTrailer();
285    
286    fOutputfile.close();    fOutputfile.close();
287    std::cout << "files closed" << endl << flush;    std::cout << "files closed" << endl << flush;
288    
289  };  };
290    
291    void Digitizer::DigitizeRunHeader(){
292      const Int_t lenRH = fRunHeaderbuffer*2;
293      UChar_t buffRH[lenRH];
294      UShort_t buffPSCU[8];
295      UChar_t *p;
296      p=buffRH;
297    
298      // header: 16 bytes
299      DigitizePSCU(fRunHeaderbuffer*2,0x20,buffPSCU);
300      memcpy(p,buffPSCU,16*sizeof(UChar_t));
301      p+=16;
302    
303      // time stamp (uint32): 0x82569c97
304      *(p++) = 0x82;
305      *(p++) = 0x56;
306      *(p++) = 0x9C;
307      *(p++) = 0x97;
308    
309      // acq_setting_mode (uint8)
310      *(p++) = 2;
311    
312      // obt (uint32)
313      ULong64_t obt = fOBT + 30LL;
314      while ( obt > 4294967295LL )
315        obt -= 4294967295LL;
316      fOBT = (UInt_t)obt;
317      //
318      *(p++) = (UChar_t)(fOBT >> 24);
319      *(p++) = (UChar_t)(fOBT >> 16);
320      *(p++) = (UChar_t)(fOBT >> 8);
321      *(p++) = (UChar_t)fOBT;
322    
323      // last time_sync_info (uint32)  (from file 000_001_00110)
324      *(p++) = 0x00;
325      *(p++) = 0x08;
326      *(p++) = 0x68;
327      *(p++) = 0xEF;
328    
329      // fav. working schedule (uint8)
330      *(p++) = 0;
331    
332      // eff. working schedule (uint8)
333      *(p++) = 0;
334    
335      // trigger_mode_A (uint32)
336      *(p++) = 0;
337      *(p++) = 0;
338      *(p++) = 0;
339      *(p++) = 0x01;
340    
341      // trigger_mode_B (uint32)
342      *(p++) = 0;
343      *(p++) = 0;
344      *(p++) = 0;
345      *(p++) = 0x03;
346    
347      // acq_after_calib (0,1) (uint8)
348      *(p++) = 0;
349    
350      // trk_calib_used (uint32)
351      *(p++) = 0;
352      *(p++) = 0;
353      *(p++) = 0;
354      *(p++) = 0x68;
355    
356      // acq_build_info (4 zero bits + 28 1's) (uint32)
357      *(p++) = 0x3F;
358      *(p++) = 0xFF;
359      *(p++) = 0xFF;
360      *(p++) = 0xFF;
361    
362      // acq_var_info (11 bits) (uint16)
363      *(p++) = 0x23;
364      *(p++) = 0x7F;
365    
366      // cal_dsp_mask (uint8)
367      *(p++) = 0;
368    
369      // crc (uint16)
370      UShort_t crcRH = (UShort_t)CM_Compute_CRC16((UINT16)0, (BYTE*)&buffRH, (UINT32)(fRunHeaderbuffer*2-2));
371      *(p++) = (UChar_t)(crcRH << 8);
372      *p = (UChar_t)crcRH;
373    
374      memcpy(fDataRunHeader,buffRH,fRunHeaderbuffer*sizeof(UShort_t));
375    };
376    
377    void Digitizer::DigitizeRunTrailer(){
378      UChar_t buffRT[fRunTrailerbuffer*2];
379      UShort_t buffPSCU[8];
380      UChar_t *p;
381      p=buffRT;
382    
383      // header: 16 bytes
384      DigitizePSCU(fRunHeaderbuffer*2,0x21,buffPSCU);
385      memcpy(p,buffPSCU,16*sizeof(UChar_t));
386      p+=16;
387    
388      // pkt_counter (uint32)
389      fCounterPhys++;
390      fCounter++;
391      while ( fCounterPhys > 16777215 )
392        fCounterPhys -= 16777215;
393      //
394      *(p++) = (UChar_t)(fCounterPhys >> 24);
395      *(p++) = (UChar_t)(fCounterPhys >> 16);
396      *(p++) = (UChar_t)(fCounterPhys >> 8);
397      *(p++) = (UChar_t)fCounterPhys;
398    
399      // pkt_readyCounter: valid packets in the run (uint32)
400      *(p++) = 0;
401      *(p++) = 0;
402      *(p++) = 0;
403      *(p++) = 0;
404    
405      // obt (uint32)
406      ULong64_t obt = fOBT + 30LL;
407      while ( obt > 4294967295LL )
408        obt -= 4294967295LL;
409      fOBT = (UInt_t)obt;
410      //
411      *(p++) = (UChar_t)(fOBT >> 24);
412      *(p++) = (UChar_t)(fOBT >> 16);
413      *(p++) = (UChar_t)(fOBT >> 8);
414      *(p++) = (UChar_t)fOBT;
415    
416      // last time_sync_info (uint32)
417      *(p++) = 0;
418      *(p++) = 0;
419      *(p++) = 0;
420      *(p++) = 0;
421    
422      // crc (uint16)
423      UShort_t crcRT = (UShort_t)CM_Compute_CRC16((UINT16)0, (BYTE*)(buffRT), (UINT32)(fRunTrailerbuffer*2-2));
424      *(p++) = (UChar_t)(crcRT << 8);
425      *p = (UChar_t)crcRT;
426    
427      memcpy(fDataRunTrailer,buffRT,fRunTrailerbuffer*sizeof(UShort_t));
428    };
429    
430  void Digitizer::AddPadding(){  void Digitizer::AddPadding(){
431    //    //
432    Float_t pd0 = (fLen+16)/64.;    Float_t pd0 = (fLen+16)/64.;
# Line 303  void Digitizer::AddPadding(){ Line 449  void Digitizer::AddPadding(){
449  };  };
450    
451    
452  void Digitizer::DigitizePSCU(UInt_t length, UChar_t type) {  void Digitizer::DigitizePSCU(UInt_t length, UChar_t type, UShort_t *pPSCU) {
453    //    //
454    UChar_t buff[16];    UChar_t buff[16];
455    //    //
# Line 355  void Digitizer::DigitizePSCU(UInt_t leng Line 501  void Digitizer::DigitizePSCU(UInt_t leng
501    //    //
502    buff[15] = (BYTE)CM_Compute_CRC16((UINT16)0, (BYTE*)&buff, (UINT32)15);    buff[15] = (BYTE)CM_Compute_CRC16((UINT16)0, (BYTE*)&buff, (UINT32)15);
503    //    //
504    memcpy(fDataPSCU,buff,16*sizeof(UChar_t));    //memcpy(fDataPSCU,buff,16*sizeof(UChar_t));
505      memcpy(pPSCU,buff,16*sizeof(UChar_t));
506    //    //
507  };  };
508    
# Line 605  void Digitizer::DigitizeCALOCALIB() { Line 752  void Digitizer::DigitizeCALOCALIB() {
752      fCALOlength++;      fCALOlength++;
753      //      //
754      UInt_t length=fCALOlength*2;      UInt_t length=fCALOlength*2;
755      DigitizePSCU(length,0x18);      DigitizePSCU(length,0x18,fDataPSCU);
756      //      //
757      // Add padding to 64 bits      // Add padding to 64 bits
758      //      //
# Line 1028  void Digitizer::DigitizeCALOFULL() { Line 1175  void Digitizer::DigitizeCALOFULL() {
1175    //    //
1176  };  };
1177    
1178  void Digitizer::DigitizeTRIGGER() {  //void Digitizer::DigitizeTRIGGER() {
1179    //fDataTrigger: 153 bytes    //fDataTrigger: 152 bytes
1180    for (Int_t j=0; j < 153; j++)    // corrected 30/11/'07 SO (was 153)
1181      fDataTrigger[j]=0x00;    //for (Int_t j=0; j < 152; j++)
1182  };    //  fDataTrigger[j]=0x00;
1183    //};
1184    
1185  Int_t Digitizer::DigitizeTOF() {  Int_t Digitizer::DigitizeTOF() {
1186    //fDataTof: 12 x 23 bytes (=276 bytes)    //fDataTof: 12 x 23 bytes (=276 bytes)
# Line 1204  Int_t Digitizer::DigitizeTOF() { Line 1352  Int_t Digitizer::DigitizeTOF() {
1352        else        else
1353          ipad=0;          ipad=0;
1354    
1355     if (ip<6) {      if (ip<6) {
1356        Paddle2Pmt(ip, ipad, &pmtleft, &pmtright);        Paddle2Pmt(ip, ipad, &pmtleft, &pmtright);
1357    
1358        // DC: evaluates mean position and path inside the paddle        // DC: evaluates mean position and path inside the paddle
# Line 1389  Int_t Digitizer::DigitizeTOF() { Line 1537  Int_t Digitizer::DigitizeTOF() {
1537      cout<<"-----------"<<endl;      cout<<"-----------"<<endl;
1538    
1539    
1540  //------ use channelmap  18-oct WM    //------ use channelmap for ToF: 18-oct WM
1541    
1542    Int_t  channelmap[] =  {3,21,11,29,19,45,27,37,36,28,44,20,5,12,13,4,    Int_t  channelmap[] =  {3,21,11,29,19,45,27,37,36,28,44,20,5,12,13,4,
1543                          6,47,14,39,22,31,30,23,38,15,46,7,0,33,16,24,                            6,47,14,39,22,31,30,23,38,15,46,7,0,33,16,24,
1544                          8,41,32,40,25,17,34,9,42,1,2,10,18,26,35,43};                            8,41,32,40,25,17,34,9,42,1,2,10,18,26,35,43};
1545    
1546    Int_t ADChelp[48];    Int_t ADChelp[48];
1547    Int_t TDChelp[48];    Int_t TDChelp[48];
# Line 1410  Int_t Digitizer::DigitizeTOF() { Line 1558  Int_t Digitizer::DigitizeTOF() {
1558    }    }
1559    
1560    
1561  // ======  write fDataTof  =======    // ======  write fDataTof  =======
1562    
1563    
1564  //  UChar_t tdcadd[8]={1,0,3,2,5,4,7,6};  (coded in 3 bit)    //  UChar_t tdcadd[8]={1,0,3,2,5,4,7,6};  (coded in 3 bit)
1565    UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192};  // DC (msb in 8 bit word )    UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192};  // DC (msb in 8 bit word )
1566        
1567    UChar_t tofBin;    UChar_t tofBin;
# Line 1445  Int_t Digitizer::DigitizeTOF() { Line 1593  Int_t Digitizer::DigitizeTOF() {
1593      fDataTof[j12+22]= EvaluateCrcTof(pTof);   // CRC      fDataTof[j12+22]= EvaluateCrcTof(pTof);   // CRC
1594      pTof+=23;      pTof+=23;
1595    };    };
1596    
1597      // ======  evaluate trigger variables  =======
1598    
1599      //fDataTrigger: 152 bytes  (corrected 30/11/'07 SO - it was 153)
1600    
1601      // initialization:
1602      for (Int_t j=0; j < 152; j++)
1603        fDataTrigger[j]=0x00;
1604      UChar_t *pTrg=fDataTrigger;
1605    
1606      // Only the variables with a (*) are modified; the others are set to 0
1607      // info given in #bites data + #bites crc
1608      // TB_READ_PMT_PLANE      :  6 + 1
1609      // TB_READ_EVENT_COUNT    :  3 + 1 (*)
1610      // TB_READ_TRIGGER_RATE   : 12 + 1
1611      // TB_READ_D_L_TIME       :  4 + 1
1612      // TB_READ_S4_CAL_COUNT   :  4 + 1
1613      // TB_READ_PMT_COUNT1     : 48 + 1
1614      // TB_READ_PMT_COUNT2     : 48 + 1
1615      // TB_READ_PATTERN_BUSY   :  8 + 1
1616      // TB_READ_PATTERN_TRIGGER:  7 + 1 (*)
1617      // TB_READ_TRIGGER_CONF   :  2 + 1 (*)
1618    
1619      // TB_READ_EVENT_COUNT
1620      fhBookTree->SetBranchStatus("Ievnt",&Ievnt);
1621      UInt_t cTrg  = (UInt_t)Ievnt;  //counter
1622      UInt_t cTrg2 = 0;  //counter with bits inverted, according to document
1623                         //"formato dati provenienti dalla trigger board"
1624      for (Int_t i=0; i < 24; i++){  // Use the first 24 bits
1625        if (cTrg & (0x1 << i) )
1626          cTrg2 = cTrg2 | (0x1 << (24-i));
1627      };
1628      fDataTrigger[7] = (UChar_t)(cTrg2 >> 16); // 8 MSbits (out  of 24)
1629      fDataTrigger[8] = (UChar_t)(cTrg2 >> 8);  // 8 "middle" bits
1630      fDataTrigger[9] = (UChar_t)(cTrg2);       // 8 LSbits
1631      pTrg=fDataTrigger+7;
1632      fDataTrigger[10]=EvaluateCrcTrigger(pTrg, 3);
1633    
1634      // TB_READ_PATTERN_TRIGGER: bytes 141-148:
1635      // PatternTrigMap[i] corresponds to bit i in TB_READ_PATTERN_TRIGGER:
1636      // mapping according to documents:
1637      // 1. "formato dati provenienti dalla trigger board"
1638      // 2. "The ToF quicklook software", Appendix A (Campana, Nagni)
1639      Int_t PatternTrigMap[]={29,42,43,1,16,7,17,28,33,41,46,2,15,8,18,27,
1640                              30,40,44,3,14,9,19,26,32,37,47,4,13,10,20,25,
1641                              34,31,38,45,5,12,21,24,36,35,39,48,6,11,22,23};
1642    
1643      for (Int_t i=0; i < 48; i++)
1644        //if (ADCtof[i]>thrTrg)
1645        if (tdc1[channelmap[i]]!=0)
1646          fDataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)]=fDataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)] | (0x1 << (PatternTrigMap[i]%8));
1647      pTrg=fDataTrigger+141;
1648      fDataTrigger[148]=EvaluateCrcTrigger(pTrg, 7);
1649    
1650      // TB_READ_TRIGGER_CONF   : set always acq.mode TOF4
1651      //
1652      // TOF1: S1-S2-S3 (&,|)
1653      // TOF4: S2-S3 (&,&)
1654      fDataTrigger[149]=0x02;
1655      fDataTrigger[150]=0x0;
1656      pTrg=fDataTrigger+149;
1657      fDataTrigger[151]=EvaluateCrcTrigger(pTrg, 2);
1658    
1659    return(0);    return(0);
1660  };  };
1661    
# Line 1498  UChar_t Digitizer::EvaluateCrcTof(UChar_ Line 1709  UChar_t Digitizer::EvaluateCrcTof(UChar_
1709    return(crcTof);    return(crcTof);
1710  }  }
1711    
1712    UChar_t Digitizer::EvaluateCrcTrigger(UChar_t *pTrg, Int_t nb) {
1713      Bool_t DEBUG=false;
1714      if (DEBUG)
1715        return(0x00);
1716    
1717      UChar_t crcTrg=0x00;
1718      UChar_t *pc=&crcTrg, *pc2;
1719      pc2=pTrg;
1720      for (Int_t jp=0; jp < nb; jp++)
1721        Crc8Tof(pc2++,pc);
1722      return(crcTrg);
1723    }
1724    
1725  void Digitizer::Crc8Tof(UChar_t *oldCRC, UChar_t *crcTof){  void Digitizer::Crc8Tof(UChar_t *oldCRC, UChar_t *crcTof){
1726    union crctof_data {    union crctof_data {
1727      UChar_t word;      UChar_t word;
# Line 1569  void Digitizer::DigitizeAC() { Line 1793  void Digitizer::DigitizeAC() {
1793    // created:  J. Conrad, KTH    // created:  J. Conrad, KTH
1794    // modified: S. Orsi, INFN Roma2    // modified: S. Orsi, INFN Roma2
1795    // fDataAC[0-63]:   main AC board    // fDataAC[0-63]:   main AC board
1796    // fDataAC[64-127]: extra AC board    // fDataAC[64-127]: extra AC board (identical to main board, for now)
1797    
1798      // We activate all branches. Once the digitization algorithm is determined
1799      // only the branches that involve needed information will be activated
1800      
1801      fhBookTree->SetBranchStatus("Ievnt",&Ievnt);
1802      fhBookTree->SetBranchStatus("Nthcat",1);
1803      fhBookTree->SetBranchStatus("Iparcat",1);
1804      fhBookTree->SetBranchStatus("Icat",1);
1805      fhBookTree->SetBranchStatus("Xincat",1);
1806      fhBookTree->SetBranchStatus("Yincat",1);
1807      fhBookTree->SetBranchStatus("Zincat",1);
1808      fhBookTree->SetBranchStatus("Xoutcat",1);
1809      fhBookTree->SetBranchStatus("Youtcat",1);
1810      fhBookTree->SetBranchStatus("Zoutcat",1);
1811      fhBookTree->SetBranchStatus("Erelcat",1);
1812      fhBookTree->SetBranchStatus("Timecat",1);
1813      fhBookTree->SetBranchStatus("Pathcat",1);
1814      fhBookTree->SetBranchStatus("P0cat",1);
1815      fhBookTree->SetBranchStatus("Nthcas",1);
1816      fhBookTree->SetBranchStatus("Iparcas",1);
1817      fhBookTree->SetBranchStatus("Icas",1);
1818      fhBookTree->SetBranchStatus("Xincas",1);
1819      fhBookTree->SetBranchStatus("Yincas",1);
1820      fhBookTree->SetBranchStatus("Zincas",1);
1821      fhBookTree->SetBranchStatus("Xoutcas",1);
1822      fhBookTree->SetBranchStatus("Youtcas",1);
1823      fhBookTree->SetBranchStatus("Zoutcas",1);
1824      fhBookTree->SetBranchStatus("Erelcas",1);
1825      fhBookTree->SetBranchStatus("Timecas",1);
1826      fhBookTree->SetBranchStatus("Pathcas",1);
1827      fhBookTree->SetBranchStatus("P0cas",1);
1828      fhBookTree->SetBranchStatus("Nthcard",1);
1829      fhBookTree->SetBranchStatus("Iparcard",1);
1830      fhBookTree->SetBranchStatus("Icard",1);
1831      fhBookTree->SetBranchStatus("Xincard",1);
1832      fhBookTree->SetBranchStatus("Yincard",1);
1833      fhBookTree->SetBranchStatus("Zincard",1);
1834      fhBookTree->SetBranchStatus("Xoutcard",1);
1835      fhBookTree->SetBranchStatus("Youtcard",1);
1836      fhBookTree->SetBranchStatus("Zoutcard",1);
1837      fhBookTree->SetBranchStatus("Erelcard",1);
1838      fhBookTree->SetBranchStatus("Timecard",1);
1839      fhBookTree->SetBranchStatus("Pathcard",1);
1840      fhBookTree->SetBranchStatus("P0card",1);
1841    
1842    fDataAC[0] = 0xACAC;    fDataAC[0] = 0xACAC;
1843    fDataAC[64]= 0xACAC;    fDataAC[64]= 0xACAC;
# Line 1595  void Digitizer::DigitizeAC() { Line 1863  void Digitizer::DigitizeAC() {
1863    
1864    // shift registers (moved to the end of the routine)    // shift registers (moved to the end of the routine)
1865    
1866    Int_t evntLSB=Ievnt%65536;    //Int_t evntLSB=Ievnt%65536;
1867    Int_t evntMSB=(Int_t)(Ievnt/65536);    //Int_t evntMSB=(Int_t)(Ievnt/65536);
1868      Int_t evntLSB=(UShort_t)Ievnt;
1869      Int_t evntMSB=Ievnt >> 16;
1870    
1871    // singles counters are dummy    // singles counters are dummy
1872    for (UInt_t i=0; i<=15; i++){  //SO Oct '07: // for (UInt_t i=0; i<=16; i++){    for (UInt_t i=0; i<=15; i++){  //SO Oct '07: // for (UInt_t i=0; i<=16; i++){
# Line 1653  void Digitizer::DigitizeAC() { Line 1923  void Digitizer::DigitizeAC() {
1923      fDataAC[i+119] = 0x1A13;      fDataAC[i+119] = 0x1A13;
1924    }    }
1925        
   // We activate all branches. Once the digitization algorithm is determined  
   // only the branches that involve needed information will be activated  
     
   fhBookTree->SetBranchAddress("Ievnt",&Ievnt);  
   fhBookTree->SetBranchStatus("Nthcat",1);  
   fhBookTree->SetBranchStatus("Iparcat",1);  
   fhBookTree->SetBranchStatus("Icat",1);  
   fhBookTree->SetBranchStatus("Xincat",1);  
   fhBookTree->SetBranchStatus("Yincat",1);  
   fhBookTree->SetBranchStatus("Zincat",1);  
   fhBookTree->SetBranchStatus("Xoutcat",1);  
   fhBookTree->SetBranchStatus("Youtcat",1);  
   fhBookTree->SetBranchStatus("Zoutcat",1);  
   fhBookTree->SetBranchStatus("Erelcat",1);  
   fhBookTree->SetBranchStatus("Timecat",1);  
   fhBookTree->SetBranchStatus("Pathcat",1);  
   fhBookTree->SetBranchStatus("P0cat",1);  
   fhBookTree->SetBranchStatus("Nthcas",1);  
   fhBookTree->SetBranchStatus("Iparcas",1);  
   fhBookTree->SetBranchStatus("Icas",1);  
   fhBookTree->SetBranchStatus("Xincas",1);  
   fhBookTree->SetBranchStatus("Yincas",1);  
   fhBookTree->SetBranchStatus("Zincas",1);  
   fhBookTree->SetBranchStatus("Xoutcas",1);  
   fhBookTree->SetBranchStatus("Youtcas",1);  
   fhBookTree->SetBranchStatus("Zoutcas",1);  
   fhBookTree->SetBranchStatus("Erelcas",1);  
   fhBookTree->SetBranchStatus("Timecas",1);  
   fhBookTree->SetBranchStatus("Pathcas",1);  
   fhBookTree->SetBranchStatus("P0cas",1);  
   fhBookTree->SetBranchStatus("Nthcard",1);  
   fhBookTree->SetBranchStatus("Iparcard",1);  
   fhBookTree->SetBranchStatus("Icard",1);  
   fhBookTree->SetBranchStatus("Xincard",1);  
   fhBookTree->SetBranchStatus("Yincard",1);  
   fhBookTree->SetBranchStatus("Zincard",1);  
   fhBookTree->SetBranchStatus("Xoutcard",1);  
   fhBookTree->SetBranchStatus("Youtcard",1);  
   fhBookTree->SetBranchStatus("Zoutcard",1);  
   fhBookTree->SetBranchStatus("Erelcard",1);  
   fhBookTree->SetBranchStatus("Timecard",1);  
   fhBookTree->SetBranchStatus("Pathcard",1);  
   fhBookTree->SetBranchStatus("P0card",1);  
   
1926    // In this simpliefied approach we will assume that once    // In this simpliefied approach we will assume that once
1927    // a particle releases > 0.5 mip in one of the 12 AC detectors it    // a particle releases > 0.5 mip in one of the 12 AC detectors it
1928    // will fire. We will furthermore assume that both cards read out    // will fire. We will furthermore assume that both cards read out
# Line 1725  void Digitizer::DigitizeAC() { Line 1951  void Digitizer::DigitizeAC() {
1951    //   6.41609e-01   +- 2.65846e-02    //   6.41609e-01   +- 2.65846e-02
1952    //   9.81177e+00   +- 1.21284e+00    //   9.81177e+00   +- 1.21284e+00
1953    // hp: 1 minimum ionising particle at 35cm from the PMT releases 1mip    // hp: 1 minimum ionising particle at 35cm from the PMT releases 1mip
   //  
   // NB: the PMT positions are needed!  
1954    
1955      TF1 *attenAC = new TF1("fAttAC",".825+.64*atan(9.8/x)",0.,45.);
1956    
1957      // PMT positions: x,y,z: (average position of the 2 PMTs)
1958      Float_t posCasPmt[4][3]={{28.308, -17.168, 63.644},    // 1 - CAS CPU: x,y,z
1959                               {18.893, 24.913, 63.644},     // 2 - CAS DCDC
1960                               {-24.307, 17.162, 63.644},    // 3 - CAS VME  
1961                               {-17.765, -28.300, 63.644}};  // 4 - CAS IPM  
1962      
1963      Float_t dAC=0.; // distance from PMT
1964      
1965    // look in CAT    // look in CAT
1966    //  for (UInt_t k= 0;k<50;k++){    //  for (UInt_t k= 0;k<50;k++){
1967    for (Int_t k= 0;k<Nthcat;k++){    for (Int_t k= 0;k<Nthcat;k++){
# Line 1737  void Digitizer::DigitizeAC() { Line 1971  void Digitizer::DigitizeAC() {
1971    
1972    // look in CAS    // look in CAS
1973    for (Int_t k= 0;k<Nthcas;k++){    for (Int_t k= 0;k<Nthcas;k++){
1974      if (Erelcas[k] >0)      if (Erelcas[k] >0) {
1975        SumEcas[Icas[k]] += Erelcas[k];        dAC=sqrt(pow((Xincas[k]+Xoutcas[k])/2 - posCasPmt[Icas[k]-1][0],2) + pow((Yincas[k]+Youtcas[k])/2 - posCasPmt[Icas[k]-1][1],2) + pow((Zincas[k]+Zoutcas[k])/2 - posCasPmt[Icas[k]-1][2],2));
1976          SumEcas[Icas[k]] += Erelcas[k]*attenAC->Eval(dAC);
1977        }
1978    };    };
1979    
1980    // look in CARD    // look in CARD
1981    for (Int_t k= 0;k<Nthcard;k++){    for (Int_t k= 0;k<Nthcard;k++){
1982      if (Erelcard[k] >0)      if (Erelcard[k] >0)
1983        SumEcard[Icard[k]] += Erelcard[k];        SumEcard[Icard[k]] += Erelcard[k];
1984    };    };
1985    
# Line 1975  void Digitizer::DigitizeDummy() { Line 2211  void Digitizer::DigitizeDummy() {
2211    }    }
2212  };  };
2213    
2214    void Digitizer::WriteRunHeader(){
2215      fOutputfile.write(reinterpret_cast<char*>(fDataRunHeader),sizeof(UShort_t)*fRunHeaderbuffer);
2216    };
2217    
2218    void Digitizer::WriteRunTrailer(){
2219      fOutputfile.write(reinterpret_cast<char*>(fDataRunTrailer),sizeof(UShort_t)*fRunTrailerbuffer);
2220    };
2221    
2222  void Digitizer::WriteData(){  void Digitizer::WriteData(){
2223    
# Line 1982  void Digitizer::WriteData(){ Line 2225  void Digitizer::WriteData(){
2225    // PSCU data are already swapped    // PSCU data are already swapped
2226    fOutputfile.write(reinterpret_cast<char*>(fDataPSCU),sizeof(UShort_t)*fPSCUbuffer);    fOutputfile.write(reinterpret_cast<char*>(fDataPSCU),sizeof(UShort_t)*fPSCUbuffer);
2227    // TRG    // TRG
2228    fOutputfile.write(reinterpret_cast<char*>(fDataTrigger),sizeof(UChar_t)*153);    fOutputfile.write(reinterpret_cast<char*>(fDataTrigger),sizeof(UChar_t)*fTRIGGERbuffer); //30/11/07 SO; it was 153
2229    // TOF    // TOF
2230    fOutputfile.write(reinterpret_cast<char*>(fDataTof),sizeof(UChar_t)*276);    fOutputfile.write(reinterpret_cast<char*>(fDataTof),sizeof(UChar_t)*fTOFbuffer);
2231    // AC    // AC
2232    UShort_t temp[1000000];    UShort_t temp[1000000];
2233    memset(temp,0,sizeof(UShort_t)*1000000);    memset(temp,0,sizeof(UShort_t)*1000000);

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23