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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Mon Apr 5 11:07:16 2010 UTC (14 years, 8 months ago) by pam-mep
Branch: yoyo
CVS Tags: start
Changes since 1.1: +0 -0 lines
first release 

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

  ViewVC Help
Powered by ViewVC 1.1.23