StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
calcRmsFluctuation.C
1 //
2 // macro to transfer data from old geometry tables to new data base structures
3 //
4 
5 void calcRmsFluctuation(const char* fileName)
6 {
7  // Baseline shared libraries
8  gSystem->Load("St_base");
9  gSystem->Load("StChain");
10  gSystem->Load("StUtilities");
11 
12  // DB-specific libs
13  gSystem->Load("libStDb_Tables.so");
14  gSystem->Load("St_Tables.so");
15  gSystem->Load("StDbLib");
16  gSystem->Load("StDbBroker");
17  gSystem->Load("geometry");
18  gSystem->Load("St_db_Maker");
19  gSystem->Load("StDaqLib");
20  gSystem->Load("StDAQMaker");
21  gSystem->Load("StSvtClassLibrary");
22  gSystem->Load("StSvtDaqMaker");
23  gSystem->Load("StSvtDbMaker");
24  gSystem->Load("StSvtCalibMaker");
25 
26  TFile *file = new TFile("rms.root","NEW");
27 
28  TH1F *histAll = new TH1F("histAll","RMS fluctuation per anode",1000,0.,20.);
29  TH1F *hist = new TH1F("hist","RMS fluctuation per anode",1000,0.,20.);
30  TH1F *hist2 = new TH1F("hist2","RMS mean per anode",1000,0.,20.);
31  TH2F *hist2D = new TH2F("hist2D","RMS fluctuation per anode vs RMS mean value",100,0.,20.,100,0.,20.);
32 
33  chain = new StChain("StChain");
34 
35  StDAQMaker *DAQMk = new StDAQMaker("DAQInput",fileName);
36  StSvtDaqMaker *svtDaqMk = new StSvtDaqMaker("SvtDaq","FULL","ZS");
37  StSvtPedMaker *svtPedMk = new StSvtPedMaker("svtPed");
38 
39  //
40  // Initialize all makers
41  //
42  //chain->Init();
43  //chain->InitRun(0);
44  DAQMk->Init();
45  svtDaqMk->Init();
46 
47  // set RMS data set
48  svtDaqMk->SetSvtRMSPed();
49 
50  //
51  // Execute Make for all makers
52  //
53  DAQMk->Make();
54  svtDaqMk->Make();
55 
56  // read RMS from DAQ file
57  svtDaqMk->GetSvtRMSPed();
58 
59  // retrieve hybrid collection of RMS
60  St_DataSet *dataSet = (TObjectSet*)svtPedMk->GetDataSet("StSvtRMSPedestal");
61  assert(dataSet);
62  StSvtHybridCollection* fSvtRms = (StSvtHybridCollection*)(dataSet->GetObject());
63  assert(fSvtRms);
64 
65  //
66  // for display purpose
67  //
68  StSvtHybridPixels* rms_temp;
69  int index_hyb;
70  float rms, rmsTotal=0, rmsSqTotal=0, rmsMean=0, rmsSqMean=0, rmsErr=0;
71 
72  // must divide rms from DAQ by 16
73  for (int barrel = 1;barrel <= fSvtRms->getNumberOfBarrels();barrel++) {
74  for (int ladder = 1;ladder <= fSvtRms->getNumberOfLadders(barrel);ladder++) {
75  for (int wafer = 1;wafer <= fSvtRms->getNumberOfWafers(barrel);wafer++) {
76  for (int hybrid = 1;hybrid <= fSvtRms->getNumberOfHybrids();hybrid++) {
77 
78  // check if the hybrid is part of the SVT
79  index_hyb = fSvtRms->getHybridIndex(barrel, ladder, wafer, hybrid);
80  if (index_hyb < 0) continue;
81  rms_temp = (StSvtHybridPixels*)fSvtRms->at(index_hyb);
82 
83  for (int anode=1; anode<=240; anode++) {
84 
85  rmsTotal=0; rmsSqTotal=0;
86  for (int time=0; time<128; time++) {
87  rms = rms_temp->At(rms_temp->getPixelIndex(anode, time))/16;
88  rms_temp->AddAt(rms,rms_temp->getPixelIndex(anode, time));
89  rmsTotal += rms;
90  rmsSqTotal += rms*rms;
91  histAll->Fill(rms);
92  }
93  rmsMean = rmsTotal/128;
94  rmsSqMean = rmsSqTotal/128;
95  rmsErr = sqrt(rmsSqMean - rmsMean*rmsMean);
96 
97  hist->Fill(rmsErr);
98  hist2->Fill(rmsMean);
99  hist2D->Fill(rmsMean,rmsErr);
100  }
101 
102  rms = rms_temp->At(rms_temp->getPixelIndex(120,64));
103  cout << "index = " << index_hyb << ", rms = " << rms << endl;
104  }
105  }
106  }
107  }
108 
109  file->Write();
110 }
virtual Int_t Make()
virtual Int_t Make()
Definition: StDAQMaker.cxx:66
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TDataSet.cxx:428