er  dev
SignalFormNEW.cpp
1 #include "TH1F.h"
2 
3 void SignalFormNEW( const char *foldername = "report", const char *ext = ".gif")
4 {
5  gSystem->Load("../libData.so");
6  using std::cout;
7  using std::endl;
8 
9  TFile *f = new TFile("../data/dataTektronix/GSItests/1000V_trigg40mv/30_60_10_50_GSI.root");
10  //TFile fr("../data/dataTektronix/GSItests/1000V_trigg40mv/30_60_10_50_GSI.root");
11  TTree *tr = (TTree*)f->Get("atree");
12 
13  const Int_t noBranches = 2;
14  Double_t ZeroTime[4],mh[4],RisTime[4],decayT[4];
15  Int_t iZero[4],PosZero[4],deltaT[4],Eh[4],Bh[4];
16  TString bName;
17  AEvent *aevent[noBranches]; // pointer to the array (of RawEvent class) in which raw data for each channel will be put
18  for (Int_t j = 0; j<noBranches; j++) {
19  aevent[j] = new AEvent(1000); //each raw event element is of class RawEvent()
20  bName.Form("Ach%d.", j);
21  tr->SetBranchAddress(bName.Data(), &aevent[j]); //read the tree tr with raw data and fill array revent with raw data
22  //cout << tr->SetBranchAddress(bName.Data(), &aevent[j]) << endl; //read the tree tr with raw data and fill array revent with raw data
23  }
24 
25  TString hname,Chname;
26  TH1F *hist[2];
27  for (Int_t i = 0; i < 2; i++) {
28  hname.Form("hist%d",i);
29  Chname.Form("Integral form of the signal",i);
30  hist[i] = new TH1F(hname.Data(), Chname.Data(), 1000, 0, 200);
31  }
32 
33  TF1 *fit1 = new TF1("fit1","-[0]*exp(-x*[1])");
34  //fit1->SetRange(-15,-5);
35  fit1->SetParName(1,"tD");
36 
37  Long64_t nEntries = tr->GetEntries();
38 
39  //loop over events
40  for (Int_t j = 0; j < nEntries; j++) {
41  //cout<<"found event number "<<j<<endl;
42  tr->GetEntry(j);
43  for(Int_t k=0;k<2;k++) { // loop for channels
44  ZeroTime[k] = aevent[k]->GetfLED(); // get fCFD for channel №k
45  iZero[k] = ZeroTime[k]*10;
46  if(j==0) { PosZero[k] = iZero[k]; }
47  deltaT[k] = iZero[k] - PosZero[k];
48  }
49 
50  for(Int_t i = 0; i<1000; i++){
51  if( ((i+deltaT[0])>-1) && ((i+deltaT[0])<1000)) hist[0]->AddBinContent(i,aevent[0]->GetOnefAmpPos(i+deltaT[0]));
52  if( ((i+deltaT[1])>-1) && ((i+deltaT[1])<1000)) hist[1]->AddBinContent(i,aevent[1]->GetOnefAmpPos(i+deltaT[1]));
53  //if( ((i+deltaT[2])>-1) && ((i+deltaT[2])<1024)) hist[2]->AddBinContent(i,aevent[2]->GetOnefAmpPos(i+deltaT[2]));
54  //if( ((i+deltaT[3])>-1) && ((i+deltaT[3])<1024)) hist[3]->AddBinContent(i,aevent[3]->GetOnefAmpPos(i+deltaT[3]));
55  }
56  }
57 
58  /* for(Int_t j=0;j<2;j++) {
59  // j=0;
60  mh[j] = hist[j]->GetBinContent(hist[j]->GetMaximumBin());
61 
62  for(Int_t i = hist[j]->GetMaximumBin(); i>0;i--) { // finding the
63  if( hist[j]->GetBinContent(i)<0.9*mh[j] ) {
64  Eh[j] = i+1;
65  break;
66  }
67  } return;
68  for(Int_t i = hist[j]->GetMaximumBin(); i>0;i--) { // finding the
69  if( hist[j]->GetBinContent(i)<0.1*mh[j] ) {
70  Bh[j] = i+1;
71  break;
72  }
73  }
74  RisTime[j] = (Eh[j] - Bh[j])*0.1; // время нарастания
75  }
76  Double_t rMin[4];
77  Double_t rMax[4];
78  rMin[0]= 141.8; rMax[0] = 150;
79  rMin[1]= 151; rMax[1] = 158.2;
80  rMin[2]= 136.8; rMax[2] = 145;
81  rMin[3]= 152.3; rMax[3] = 161;*/
82  TCanvas *c1 = new TCanvas("c1","test",10,10,1000,600);
83  //c1->Divide(2,2);
84  i=0;
85  //for(Int_t i=0;i<2;i++)
86  {
87  //c1->cd(i+1);
88  hist[i]->GetYaxis()->SetTitle("Signal [V]");
89  hist[i]->GetYaxis()->CenterTitle();
90 
91  hist[i]->GetXaxis()->SetTitle("Time [ns]");
92  hist[i]->GetXaxis()->CenterTitle();
93 
94  hist[i]->GetXaxis()->SetRangeUser(75, 135);
95 
96  hist[i]->Draw();
97  //fit1->SetParLimits(0,-3e+30,-1e+10);
98  //fit1->SetParLimits(1,1e-2,1);
99  //fit1->SetRange(rMin[i],rMax[i]);
100  //hist[i]->Fit("fit1","R");
101  //decayT[i] = 1/(fit1->GetParameter(1));
102  c1->Update();
103  }
104 
105  /*for(Int_t i=0;i<4;i++) {
106  cout<<decayT[i]<<" that's decay time of channel number "<<i<<endl;
107  cout<<RisTime[i]<< " that's a RiseTime for this channel "<<i<<endl;
108  }
109  c1->Print(Form("../macros/picsDRS4/%s/IntegralForm%s", foldername, ext));*/
110 }