StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MinvLikeSignCorrFctn.cxx
1 /***************************************************************************
2  *
3  * $Id: MinvLikeSignCorrFctn.cxx,v 1.4 2003/01/31 19:21:09 magestro Exp $
4  *
5  * Author: Frank Laue, Ohio State, laue@mps.ohio-state.edu
6  ***************************************************************************
7  *
8  * Description: part of STAR HBT Framework: StHbtMaker package
9  * A simple invariant-mass correlation function
10  *
11  ***************************************************************************
12  *
13  **************************************************************************/
14 //#ifndef __CINT__
15 //#include "fortranc.h"
16 //#define fortrantest F77_NAME(fortrantest,FORTRANTEST)
17 //extern "C" {int type_of_call F77_NAME(fortrantest,FORTRANTEST)(int*);}
18 //#endif
19 
20 #include "StHbtMaker/CorrFctn/MinvLikeSignCorrFctn.h"
21 #include <cstdio>
22 
23 #ifdef __ROOT__
24 ClassImp(MinvLikeSignCorrFctn)
25 #endif
26 
27 //____________________________
28 MinvLikeSignCorrFctn::MinvLikeSignCorrFctn(char* title1, char* title2,
29  const int& nbins, const float& MinvLo, const float& MinvHi){
30 #ifdef __ROOT__
31  mTagWriter = StHbtTagWriter::Instance(); // get the singleton
32 #endif
33 
34  char theTitle1[100];
35  char theTitle2[100];
36  sprintf(theTitle2,"%s",title2);
37  // set up numerator
38  sprintf(theTitle1,"MinvLikeSignCorrFctnNum_%s",title1);
39  mNumerator = new StHbt1DHisto(theTitle1,theTitle2,nbins,MinvLo,MinvHi);
40  // set up denominator
41  sprintf(theTitle1,"MinvLikeSignCorrFctnMixedEventDen_%s",title1);
42  mMixedEventDenominator = new StHbt1DHisto(theTitle1,theTitle2,nbins,MinvLo,MinvHi);
43  // set up denominator
44  sprintf(theTitle1,"MinvLikeSignCorrFctnPositiveDen_%s",title1);
45  mPositiveDenominator = new StHbt1DHisto(theTitle1,theTitle2,nbins,MinvLo,MinvHi);
46  // set up denominator
47  sprintf(theTitle1,"MinvLikeSignCorrFctnNegativeDen_%s",title1);
48  mNegativeDenominator = new StHbt1DHisto(theTitle1,theTitle2,nbins,MinvLo,MinvHi);
49  // set up difference
50  sprintf(theTitle1,"MinvLikeSignCorrFctnMixedEventDif_%s",title1);
51  mMixedEventDifference = new StHbt1DHisto(theTitle1,theTitle2,nbins,MinvLo,MinvHi);
52  // set up difference
53  sprintf(theTitle1,"MinvLikeSignCorrFctnLikeSignDif_%s",title1);
54  mLikeSignDifference = new StHbt1DHisto(theTitle1,theTitle2,nbins,MinvLo,MinvHi);
55  // this next bit is unfortunately needed so that we can have many histos of same "title"
56  // it is neccessary if we typedef StHbt1DHisto to TH1d (which we do)
57  mNumerator->SetDirectory(0);
58  mMixedEventDenominator->SetDirectory(0);
59  mPositiveDenominator->SetDirectory(0);
60  mNegativeDenominator->SetDirectory(0);
61  mMixedEventDifference->SetDirectory(0);
62  mLikeSignDifference->SetDirectory(0);
63 
64  mNumerator->Sumw2();
65  mMixedEventDenominator->Sumw2();
66  mPositiveDenominator->Sumw2();
67  mNegativeDenominator->Sumw2();
68  mMixedEventDifference->Sumw2();
69  mLikeSignDifference->Sumw2();
70 
71  // for (int i=0; i < 100; i++) {
72  // int j = fortrantest( &i );
73  // }
74 }
75 
76 //____________________________
77 MinvLikeSignCorrFctn::~MinvLikeSignCorrFctn(){
78  delete mNumerator;
79  delete mMixedEventDenominator;
80  delete mPositiveDenominator;
81  delete mNegativeDenominator;
82  delete mMixedEventDifference;
83  delete mLikeSignDifference;
84 }
85 //_________________________
86 void MinvLikeSignCorrFctn::Finish(){
87  int NEvents = 1;
88  if ( dynamic_cast<StHbtAnalysis*>( HbtAnalysis() ) ) {
89  if ( dynamic_cast<mikesEventCut*>( ((StHbtAnalysis*)HbtAnalysis())->EventCut() ) )
90  NEvents = ((mikesEventCut*)((StHbtAnalysis*)HbtAnalysis())->EventCut())->NEventsPassed();
91  }
92 
93  mNumerator->Scale(1./NEvents);
94  mMixedEventDenominator->Scale(1./NEvents);
95  mPositiveDenominator->Scale(1./NEvents);
96  mNegativeDenominator->Scale(1./NEvents);
97  mMixedEventDifference->Scale(1./NEvents);
98  mLikeSignDifference->Scale(1./NEvents);
99 
100  double NumeratorInt = mNumerator->Integral();
101  double MixedEventDenominatorInt = mMixedEventDenominator->Integral();
102  mMixedEventDifference->Add(mNumerator,mMixedEventDenominator,1.0,-1*NumeratorInt/MixedEventDenominatorInt);
103  mLikeSignDifference->Add(mNumerator,mPositiveDenominator,1.,-1.);
104  mLikeSignDifference->Add(mLikeSignDifference,mNegativeDenominator,1.,-1.);
105 
106 }
107 //____________________________
108 StHbtString MinvLikeSignCorrFctn::Report(){
109  string stemp = "Minv Correlation Function Report:\n";
110  char ctemp[100];
111  sprintf(ctemp,"Number of entries in numerator:\t%E\n",mNumerator->GetEntries());
112  stemp += ctemp;
113  sprintf(ctemp,"Number of entries in mixed event denominator:\t%E\n",mMixedEventDenominator->GetEntries());
114  stemp += ctemp;
115  sprintf(ctemp,"Number of entries in like sign positive denominator:\t%E\n",mPositiveDenominator->GetEntries());
116  stemp += ctemp;
117  sprintf(ctemp,"Number of entries in like sign negative denominator:\t%E\n",mNegativeDenominator->GetEntries());
118  stemp += ctemp;
119  sprintf(ctemp,"Number of entries in mixed event difference:\t%E\n",mMixedEventDifference->GetEntries());
120  stemp += ctemp;
121  sprintf(ctemp,"Number of entries in like sign difference:\t%E\n",mLikeSignDifference->GetEntries());
122  stemp += ctemp;
123  StHbtString returnThis = stemp;
124  return returnThis;
125 }
126 //____________________________
127 inline void MinvLikeSignCorrFctn::AddRealPair(const StHbtPair* pair){
128  mNumerator->Fill(pair->mInv());
129 }
130 //____________________________
131 inline void MinvLikeSignCorrFctn::AddMixedPair(const StHbtPair* pair){
132  mMixedEventDenominator->Fill(pair->mInv());
133 }
134 //____________________________
135 inline void MinvLikeSignCorrFctn::AddLikeSignPositivePair(const StHbtPair* pair){
136  mPositiveDenominator->Fill(pair->mInv());
137 }
138 //____________________________
139 inline void MinvLikeSignCorrFctn::AddLikeSignNegativePair(const StHbtPair* pair){
140  mNegativeDenominator->Fill(pair->mInv());
141 }
142 
143