00001 #include "StEEmcMixQAMaker.h"
00002 #include "StEEmcMixMaker.h"
00003 #include "StEEmcPointMaker.h"
00004 #include "TH1F.h"
00005 #include "TH2F.h"
00006 #include <stdio.h>
00007 #include <iostream>
00008
00009 ClassImp(StEEmcMixQAMaker);
00010
00011
00012 StEEmcMixQAMaker::StEEmcMixQAMaker(const Char_t *name):StMaker(name)
00013 {
00014
00016 maxPerSector = 100;
00017 maxPerEvent = 100;
00018 maxPerCluster = 2;
00019
00020
00021 zVertexMin=-150.0;
00022 zVertexMax= 50.0;
00023
00025 mBins.push_back(0.);
00026 mBins.push_back(1.0);
00027 mBins.push_back(2.0);
00028 mBins.push_back(3.0);
00029 mBins.push_back(4.0);
00030 mBins.push_back(6.0);
00031 mBins.push_back(8.0);
00032 mBins.push_back(10.0);
00033 mBins.push_back(15.0);
00034 mBins.push_back(20.0);
00035 mBins.push_back(200.0);
00036
00037 mBackground = false;
00038
00039 }
00040
00041
00042 Int_t StEEmcMixQAMaker::Init()
00043 {
00044
00045
00046 hNcandidates = new TH1F("hNcandidates","Number of pairs",30,0.,30.);
00047
00048 hMassRall=new TH1F("hMassRall","Dipoint invariant mass, integrated",360,0.,3.6);
00049 hZvertexRall=new TH1F("hZvertexRall","Event vertex",150,-150.,150.);
00050
00052 for ( Int_t sec=0;sec<13;sec++ )
00053 {
00054 TString name="hYXpair";name+=sec+1;
00055 TString title="Y vs X [cm] of stable pi0, sector ";title+=sec+1;
00056 hYXpair.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
00057 name="hYXhigh";name+=sec+1;
00058 title="Y vs X [cm] of higher energy gamma, sector ";title+=sec+1;
00059 hYXhigh.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
00060 name.ReplaceAll("high","low");
00061 title.ReplaceAll("high","low");
00062 hYXlow.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
00063 name="hE1E2sec";name+=sec+1;
00064 title="Energy point1 vs Energy point2 [GeV], sector ";title+=sec+1;
00065 hE1E2.push_back(new TH2F(name,title,100,0.,50.,100,0.,50.));
00066 }
00067
00068
00069
00071 for ( Int_t sec=0;sec<13;sec++ )
00072 {
00073
00075 std::vector<TH1F *> tmp;
00076 hMassR.push_back( tmp );
00077 hZvertexR.push_back( tmp );
00078 hZggR.push_back( tmp );
00079 hPhiggR.push_back( tmp );
00080 hEnergyR.push_back( tmp );
00081
00082 TString sec_name = "-sec";sec_name+=sec+1;
00083 for ( UInt_t ptbin=0;ptbin<mBins.size()-1;ptbin++ )
00084 {
00085
00086 TString bin_name = "-bin";bin_name+=ptbin;
00087
00088 TString hname="hMassR";hname+=sec_name;hname+=bin_name;
00089 TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
00090 htitle+=", ptbin="; htitle+=(Int_t)ptbin;
00091 hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.60) );
00092
00093 hname="hZvertexR";hname+=sec_name;hname+=bin_name;
00094 htitle="Event vertex";htitle+=sec+1;
00095 htitle+=", ptbin="; htitle+=(Int_t)ptbin;
00096 hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
00097
00098 hname="hZggR";hname+=sec_name;hname+=bin_name;
00099 htitle="Zgg = |E1-E2|/E, sector= ";htitle+=sec+1; htitle+=", ptbin=";htitle+=(Int_t)ptbin;
00100 hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
00101
00102 hname="hPhiggR";hname+=sec_name;hname+=bin_name;
00103 htitle="Opening angle, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
00104 hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
00105
00106 hname="hEnergyR";hname+=sec_name;hname+=bin_name;
00107 htitle+="Energy, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
00108 hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
00109
00110 }
00111
00113 TString hname="hMassR";hname+=sec_name;hname+="-unbinned";
00114 TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
00115 hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.6) );
00116
00117 hname="hZvertexR";hname+=sec_name;hname+="-unbinned";
00118 htitle="Event vertex, sector=";htitle+=sec+1;
00119 hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
00120
00121 hname="hZggR";hname+=sec_name;hname+="-unbinned";
00122 htitle="Zgg = |E1-E2|/E, sector=";htitle+=sec+1;
00123 hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
00124
00125 hname="hPhiggR";hname+=sec_name;hname+="-unbinned";
00126 htitle="Opening angle, sector=";htitle+=sec+1;
00127 hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
00128
00129 hname="hEnergyR";hname+=sec_name;hname+="-unbinned";
00130 htitle+="Energy, sector=";htitle+=sec+1;
00131 hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
00132 }
00133
00134
00135
00136 return StMaker::Init();
00137 }
00138
00139
00140 Int_t StEEmcMixQAMaker::Make()
00141 {
00142
00146 std::vector< StEEmcPairVec_t > pairs;
00147 for ( Int_t sec=0;sec<12;sec++ )
00148 {
00149 StEEmcPairVec_t tmp;
00150 pairs.push_back(tmp);
00151 }
00152
00153 hNcandidates -> Fill( mEEmixer -> numberOfCandidates() );
00154
00155
00159 if ( !mBackground )
00160 {
00161
00163 if ( mEEmixer -> numberOfCandidates() > maxPerEvent ) return kStOK;
00164
00165 for ( Int_t i=0;i<mEEmixer->numberOfCandidates();i++ )
00166 {
00167
00168 StEEmcPair p = mEEmixer -> candidate(i);
00169 pairs[ p.point(0).sector() ].push_back(p);
00170
00171 }
00172
00173 }
00177 else
00178 {
00179
00181 if ( mEEmixer -> numberOfMixedCandidates() > maxPerEvent ) return kStOK;
00182
00183 for ( Int_t i=0;i<mEEmixer->numberOfMixedCandidates();i++ )
00184 {
00185
00186 StEEmcPair p = mEEmixer -> mixedCandidate(i);
00187 pairs[ p.point(0).sector() ].push_back(p);
00188
00189 }
00190
00191 }
00192
00193
00194
00195
00196
00200 for ( UInt_t sec=0;sec<12;sec++ )
00201 {
00202
00204 if ( pairs[sec].size() > (UInt_t)maxPerSector ) continue;
00205
00206
00207 for ( UInt_t i=0;i<pairs[sec].size();i++ )
00208 {
00209
00210 StEEmcPair pair = pairs[sec][i];
00211
00213 if ( !twoBodyCut( pair ) ) continue;
00214
00216 Int_t bin = ptbin( pair );
00217 std::cout << "sector=" << sec << " mass=" << pair.mass() << " pt = " << pair.pt() << " bin=" << bin << std::endl;
00218 if ( bin < 0 ) continue;
00219
00221 if ( pair.vertex().Z() < zVertexMin ||
00222 pair.vertex().Z() > zVertexMax ) continue;
00223
00225 hMassR[sec][bin] -> Fill( pair.mass() );
00226 hMassR[ 12][bin] -> Fill( pair.mass() );
00227 hMassRall -> Fill( pair.mass() );
00228
00229 hMassR[sec].back() -> Fill( pair.mass() );
00230 hMassR[ 12].back() -> Fill( pair.mass() );
00231
00233 if ( pair.mass() > mMin && pair.mass() <= mMax )
00234 {
00235
00237 hZvertexR[sec][bin] -> Fill( pair.vertex().Z() );
00238 hZvertexR[ 12][bin] -> Fill( pair.vertex().Z() );
00239 hZvertexRall -> Fill( pair.vertex().Z() );
00240
00241 hZvertexR[sec].back() -> Fill( pair.vertex().Z() );
00242 hZvertexR[ 12].back() -> Fill( pair.vertex().Z() );
00243
00245
00246 StEEmcPoint point1=pair.point(0);
00247 StEEmcPoint point2=pair.point(1);
00248
00249 TVector3 pos1 = point1.position();
00250 TVector3 pos2 = point2.position();
00251
00252 Float_t e1=point1.energy();
00253 Float_t e2=point2.energy();
00254
00255 TVector3 posp = ( e1 * pos1 + e2 * pos2 ) * ( 1.0/(e1+e2) );
00256
00257 hYXpair[sec] -> Fill( posp.X(), posp.Y() );
00258 hYXhigh[sec] -> Fill( pos1.X(), pos1.Y() );
00259 hYXlow[sec] -> Fill( pos2.X(), pos2.Y() );
00260 hE1E2[sec] -> Fill( e2, e1 );
00261
00262 hYXpair[ 12] -> Fill( posp.X(), posp.Y() );
00263 hYXhigh[ 12] -> Fill( pos1.X(), pos1.Y() );
00264 hYXlow[ 12] -> Fill( pos2.X(), pos2.Y() );
00265 hE1E2[ 12] -> Fill( e2, e1 );
00266
00267 }
00268
00269 }
00270
00271 }
00272
00273 return kStOK;
00274 }
00275
00276
00277
00278 Int_t StEEmcMixQAMaker::ptbin( StEEmcPair pair )
00279 {
00280 for ( UInt_t i=0;i<mBins.size()-1;i++ )
00281 {
00282 if ( pair.pt() > mBins[i] && pair.pt() <= mBins[i+1] ) return (Int_t)i;
00283 }
00284 return -1;
00285 }
00286
00287
00288 void StEEmcMixQAMaker::mixer(const Char_t *name, Float_t min, Float_t max)
00289 {
00290 mEEmixer=(StEEmcMixMaker *)GetMaker(name);
00291 assert(mEEmixer);
00292 mMin=min;
00293 mMax=max;
00294 assert(max>min && max>0.);
00295 }
00296
00297
00298 void StEEmcMixQAMaker::points(const Char_t *name)
00299 {
00300 mEEpoints=(StEEmcPointMaker *)GetMaker(name);
00301 assert(mEEpoints);
00302 }
00303
00304
00305 Bool_t StEEmcMixQAMaker::twoBodyCut( StEEmcPair pair )
00306 {
00307
00309
00310 Bool_t towers[720]; for (Int_t i=0;i<720;i++ ) towers[i]=false;
00311 StEEmcTower t1 = pair.point(0).tower(0);
00312 StEEmcTower t2 = pair.point(1).tower(0);
00313
00314 for ( Int_t i=0;i<t1.numberOfNeighbors();i++ ) {
00315 StEEmcTower mytow=t1.neighbor(i);
00316 towers[ mytow.index() ] = true;
00317 }
00318 for ( Int_t i=0;i<t2.numberOfNeighbors();i++ ) {
00319 StEEmcTower mytow=t2.neighbor(i);
00320 towers[ t2.neighbor(i).index() ] = true;
00321 }
00322
00323
00324 towers[ t1.index() ] = true;
00325 towers[ t2.index() ] = true;
00326
00328
00331
00332
00333 Int_t count = 0;
00334 for ( Int_t i=0;i<mEEpoints->numberOfPoints();i++ )
00335 {
00336 StEEmcPoint p=mEEpoints->point(i);
00337 StEEmcTower t=p.tower(0);
00338 if ( towers[ t.index() ] ) count++;
00339 }
00340
00341 return ( count <= maxPerCluster );
00342
00343 }