/[PAMELA software]/PamCut/CollectionActions/Histo2DActions/MassVsRigHistoAction/MassVsRigHistoAction.cpp
ViewVC logotype

Contents of /PamCut/CollectionActions/Histo2DActions/MassVsRigHistoAction/MassVsRigHistoAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Tue Apr 20 10:26:25 2010 UTC (14 years, 7 months ago) by pam-mep
Branch: MAIN
CVS Tags: Root_V8, MergedToHEAD_1, nuclei_reproc, MergedFromV8_1, BeforeMergingFromV8_1, V9, HEAD
Branch point for: V8
Changes since 1.3: +4 -2 lines
Bugs fixed

1 /*
2 * MassVsRigHistoAction.cpp
3 *
4 * Created on: 28-marth-2010
5 * Author: Vitaly Malakhov
6 */
7
8 /*! @file MassVsRigHistoAction.cpp The MassVsRigHistoAction class implementation file. */
9
10 #include "MassVsRigHistoAction.h"
11 #include "TMath.h"
12
13 MassVsRigHistoAction::MassVsRigHistoAction(const char *actionName, TString outFileBase, TString mode,
14 bool outRoot, bool outText, TString title, Int_t Z, TString rigBinFile) :
15 Histo2DAction<Int_t> (actionName, title, outFileBase, mode, outRoot, outText), _Z(Z), _rigBinFile(rigBinFile){
16
17 }
18
19 void MassVsRigHistoAction::OnGood(PamLevel2 *event) {
20 Float_t betaev = event->GetTrack(0)->GetToFTrack()->beta[12];
21 Float_t rigev = 1./event->GetTrack(0)->GetTrkTrack()->GetDeflection();
22 Float_t Mass = 0;
23 if(TMath::Abs(betaev) <= 1.) Mass = _Z*rigev*sqrt(pow(betaev,-2)-1);
24 else Mass = -_Z*rigev*sqrt(1-pow(betaev,-2));
25 Fill(rigev, Mass);
26 }
27
28 void MassVsRigHistoAction::Finalize() {
29
30 Histo2DAction<Int_t>::Finalize();
31
32 ifstream binListFile;
33 binListFile.open(_rigBinFile);
34
35 TString auxString;
36 _xRBins.resize(0);
37 while (!binListFile.eof()) {
38 binListFile >> auxString;
39 if (auxString != "") {
40 _xRBins.push_back(auxString.Atof());
41 }
42 }
43 binListFile.close();
44
45 TH1F tmphisto;
46 tmphisto.SetBins(GetRootHisto()->GetNbinsY(),GetRootHisto()->GetXaxis()->GetXmin(),GetRootHisto()->GetXaxis()->GetXmax());
47
48 for (UInt_t i=0; i < _xRBins.size()-1 ;i++){
49 _fixedRigHisto.push_back(tmphisto);
50 ostringstream ss1(ostringstream::out);
51 ss1 << _xRBins[i];
52 ostringstream ss2(ostringstream::out);
53 ss2 << _xRBins[i+1];
54 TString s1 = ss1.str();
55 TString s2 = ss2.str();
56 for(Int_t j = 0; j<s1.Sizeof()-1; j++) if(s1[j] == '.') s1[j] = 'p';
57 for(Int_t j = 0; j<s2.Sizeof()-1; j++) if(s2[j] == '.') s2[j] = 'p';
58 _fixedRigHisto[i].SetName((TString)GetName()+"_Rig"+s1+"_"+s2+"GV");
59 _fixedRigHisto[i].SetTitle((TString)GetName()+"_Rig"+s1+"_"+s2+"GV");
60 for(Int_t k = 0; k < GetRootHisto()->GetNbinsY(); k++){
61 Float_t sumbins = 0;
62 for(Int_t j = 0; j < GetRootHisto()->GetNbinsX(); j++){
63 if(GetRootHisto()->GetXaxis()->GetBinUpEdge(j) > _xRBins[i] && GetRootHisto()->GetXaxis()->GetBinLowEdge(j) < _xRBins[i+1]) sumbins += GetRootHisto()->GetBinContent(j,k);
64 }
65 _fixedRigHisto[i].SetBinContent(k,sumbins);
66 }
67 }
68 TFile outRootFile((Histo2DAction<Int_t>::_outFileBase + ".root"), "UPDATE");
69 outRootFile.cd();
70 for (UInt_t i=0; i < _xRBins.size()-1 ;i++)
71 _fixedRigHisto[i].Write();
72 outRootFile.Close();
73
74 }

  ViewVC Help
Powered by ViewVC 1.1.23