#include <sstream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "Riostream.h"
#include "TFile.h"
#include "TDirectory.h"
#include "TTree.h"
#include "TLeafI.h"
#include "TH1.h"
#include "TH2.h"
#include "TF1.h"
#include "TMath.h"
#include "TRandom.h"
#include "TSQLServer.h"
#include "TSystem.h"
#include "CalibTrk1Event.h"
#include "CalibTrk2Event.h"
//
#include "Digitizer.h"
#include "CRC.h"
//
#include <PamelaRun.h>
#include <physics/calorimeter/CalorimeterEvent.h>
#include <CalibCalPedEvent.h>
#include "GLTables.h"

void Digitizer::DigitizeND(){
  // creato:  S. Borisov, INFN Roma2 e MEPHI, Sett 2007
  Int_t i=0;
  UShort_t NdN=0;
//   fhBookTree->SetBranchStatus("Nthnd",1);//modified by E.Vannuccini 03/08
//   fhBookTree->SetBranchStatus("Itubend",1);
//   fhBookTree->SetBranchStatus("Iparnd",1);  
//   fhBookTree->SetBranchStatus("Xinnd",1);
//   fhBookTree->SetBranchStatus("Yinnd",1);
//   fhBookTree->SetBranchStatus("Zinnd",1);
//   fhBookTree->SetBranchStatus("Xoutnd",1);
//   fhBookTree->SetBranchStatus("Youtnd",1);
//   fhBookTree->SetBranchStatus("Zoutnd",1);
//   fhBookTree->SetBranchStatus("Erelnd",1);
//   fhBookTree->SetBranchStatus("Timend",1);
//   fhBookTree->SetBranchStatus("Pathnd",1);
//   fhBookTree->SetBranchStatus("P0nd",1);
  //cout<<"n="<<Nthnd<<"  "<<NdN<<"\n";
  for(i=0;i<Nthnd;i++){
    if(Iparnd[i]==13){
      NdN++;
    }
  }
  //NdN=100; //only for debug

  for(i=0;i<3;i++){
    fDataND[2*i]=0x0000;
    fDataND[2*i+1]=0x010F;
  }
  fDataND[0]=0xFF00 & (256*NdN);
}
