00001
00038 #include "StEEmcMixQAMaker.h"
00039 #include "StEEmcMixMaker.h"
00040 #include "StEEmcPool/StEEmcPointMaker/StEEmcPointMaker.h"
00041 #include "TH1F.h"
00042 #include "TH2F.h"
00043 #include <stdio.h>
00044 #include <iostream>
00045
00046 ClassImp(StEEmcMixQAMaker);
00047
00048
00049 StEEmcMixQAMaker::StEEmcMixQAMaker(const Char_t *name):StMaker(name)
00050 {
00051
00053 maxPerSector = 100;
00054 maxPerEvent = 100;
00055 maxPerCluster = 2;
00056
00057 zVertexMin=-150.0;
00058 zVertexMax= 150.0;
00059
00060 minZgg = 0.0;
00061 maxZgg = 1.0;
00062
00063 minTowerFrac = 0.0;
00064
00066 mBins.push_back(0.);
00067 mBackground = false;
00068
00069 }
00070
00071
00072 Int_t StEEmcMixQAMaker::Init()
00073 {
00074
00075
00076 hNcandidates = new TH1F("hNcandidates","Number of pairs",30,0.,30.);
00077 hNcandidatesR = new TH1F("hNcandidatesR","Number of pairs [0.1,0.18] per sector",12,0.,12.);
00078
00079 hMassRall=new TH1F("hMassRall","Dipoint invariant mass, integrated",360,0.,3.6);
00080 hZvertexRall=new TH1F("hZvertexRall","Event vertex",150,-150.,150.);
00081
00083 for ( Int_t sec=0;sec<13;sec++ )
00084 {
00085 TString name="hYXpair";name+=sec+1;
00086 TString title="Y vs X [cm] of stable pi0, sector ";title+=sec+1;
00087 hYXpair.push_back(new TH2F(name,title,125,-250.,250.,125,-250.,250.));
00088 name="hYXhigh";name+=sec+1;
00089 title="Y vs X [cm] of higher energy gamma, sector ";title+=sec+1;
00090 hYXhigh.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
00091 name.ReplaceAll("high","low");
00092 title.ReplaceAll("high","low");
00093 hYXlow.push_back(new TH2F(name,title,250,-250.,250.,250,-250.,250.));
00094 name="hE1E2sec";name+=sec+1;
00095 title="Energy point1 vs Energy point2 [GeV], sector ";title+=sec+1;
00096 hE1E2.push_back(new TH2F(name,title,100,0.,50.,100,0.,50.));
00097 }
00098
00099
00100
00102 for ( Int_t sec=0;sec<13;sec++ )
00103 {
00104
00106 std::vector<TH1F *> tmp;
00107 hMassR.push_back( tmp );
00108 hZvertexR.push_back( tmp );
00109 hZggR.push_back( tmp );
00110 hPhiggR.push_back( tmp );
00111 hEnergyR.push_back( tmp );
00112
00113 TString sec_name = "-sec";sec_name+=sec+1;
00114 for ( UInt_t ptbin=0;ptbin<mBins.size()-1;ptbin++ )
00115 {
00116
00117 TString bin_name = "-bin";bin_name+=ptbin;
00118
00119 TString hname="hMassR";hname+=sec_name;hname+=bin_name;
00120 TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
00121 htitle+=", ptbin="; htitle+=(Int_t)ptbin;
00122 hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.60) );
00123
00124 hname="hZvertexR";hname+=sec_name;hname+=bin_name;
00125 htitle="Event vertex";htitle+=sec+1;
00126 htitle+=", ptbin="; htitle+=(Int_t)ptbin;
00127 hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
00128
00129 hname="hZggR";hname+=sec_name;hname+=bin_name;
00130 htitle="Zgg = |E1-E2|/E, sector= ";htitle+=sec+1; htitle+=", ptbin=";htitle+=(Int_t)ptbin;
00131 hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
00132
00133 hname="hPhiggR";hname+=sec_name;hname+=bin_name;
00134 htitle="Opening angle, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
00135 hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
00136
00137 hname="hEnergyR";hname+=sec_name;hname+=bin_name;
00138 htitle+="Energy, sector=";htitle+=sec+1;htitle+=", ptbin=";htitle+=(Int_t)ptbin;
00139 hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
00140
00141 }
00142
00144 TString hname="hMassR";hname+=sec_name;hname+="-unbinned";
00145 TString htitle="Dipoint invariant mass, sector=";htitle+=sec+1;
00146 hMassR[sec].push_back( new TH1F(hname,htitle,360,0.,3.6) );
00147
00148 hname="hZvertexR";hname+=sec_name;hname+="-unbinned";
00149 htitle="Event vertex, sector=";htitle+=sec+1;
00150 hZvertexR[sec].push_back(new TH1F(hname,htitle,150,-150.,150.));
00151
00152 hname="hZggR";hname+=sec_name;hname+="-unbinned";
00153 htitle="Zgg = |E1-E2|/E, sector=";htitle+=sec+1;
00154 hZggR[sec].push_back(new TH1F(hname,htitle,50,0.,1.));
00155
00156 hname="hPhiggR";hname+=sec_name;hname+="-unbinned";
00157 htitle="Opening angle, sector=";htitle+=sec+1;
00158 hPhiggR[sec].push_back(new TH1F(hname,htitle,50,0.,0.1));
00159
00160 hname="hEnergyR";hname+=sec_name;hname+="-unbinned";
00161 htitle+="Energy, sector=";htitle+=sec+1;
00162 hEnergyR[sec].push_back(new TH1F(hname,htitle,50,0.,50.));
00163
00164 }
00165
00166
00167
00168 return StMaker::Init();
00169 }
00170
00171
00172 Int_t StEEmcMixQAMaker::Make()
00173 {
00174
00178 std::vector< StEEmcPairVec_t > pairs;
00179 for ( Int_t sec=0;sec<12;sec++ )
00180 {
00181 StEEmcPairVec_t tmp;
00182 pairs.push_back(tmp);
00183 }
00184
00185 hNcandidates -> Fill( mEEmixer -> numberOfCandidates() );
00186
00190 if ( !mBackground )
00191 {
00192
00194 if ( mEEmixer -> numberOfCandidates() > maxPerEvent ) return kStOK;
00195
00196 for ( Int_t i=0;i<mEEmixer->numberOfCandidates();i++ )
00197 {
00198
00199 StEEmcPair p = mEEmixer -> candidate(i);
00200 pairs[ p.point(0).sector() ].push_back(p);
00201
00202 }
00203
00204 }
00208 else
00209 {
00210
00212 if ( mEEmixer -> numberOfMixedCandidates() > maxPerEvent ) return kStOK;
00213
00214 for ( Int_t i=0;i<mEEmixer->numberOfMixedCandidates();i++ )
00215 {
00216
00217 StEEmcPair p = mEEmixer -> mixedCandidate(i);
00218 pairs[ p.point(0).sector() ].push_back(p);
00219
00220 }
00221
00222 }
00223
00224
00225
00226
00227
00231 for ( UInt_t sec=0;sec<12;sec++ )
00232 {
00233
00235 if ( pairs[sec].size() > (UInt_t)maxPerSector ) continue;
00236
00237
00238 for ( UInt_t i=0;i<pairs[sec].size();i++ )
00239 {
00240
00241 StEEmcPair pair = pairs[sec][i];
00242
00244 if ( !twoBodyCut( pair ) ) continue;
00245
00247 Int_t bin = ptbin( pair );
00248 std::cout << "pair=" << i << " ptmin=" << mBins[bin] << " ptmax=" << mBins[bin+1] << " mass=" << pair.mass() << " zgg=" << pair.zgg() << std::endl;
00249
00253
00255 if ( pair.zgg() < minZgg || pair.zgg() > maxZgg ) continue;
00256
00258 if ( pair.vertex().Z() < zVertexMin ||
00259 pair.vertex().Z() > zVertexMax ) continue;
00260
00262 if ( bin>=0 ) hMassR[sec][bin] -> Fill( pair.mass() );
00263 if ( bin>=0 ) hMassR[ 12][bin] -> Fill( pair.mass() );
00264 hMassRall -> Fill( pair.mass() );
00265
00266 hMassR[sec].back() -> Fill( pair.mass() );
00267 hMassR[ 12].back() -> Fill( pair.mass() );
00268
00270 if ( pair.mass() > mMin && pair.mass() <= mMax )
00271 {
00272
00273 hNcandidatesR->Fill( pair.point(0).sector() ) ;
00274
00276 if ( bin>=0 ) hZvertexR[sec][bin] -> Fill( pair.vertex().Z() );
00277 if ( bin>=0 ) hZvertexR[ 12][bin] -> Fill( pair.vertex().Z() );
00278 hZvertexRall -> Fill( pair.vertex().Z() );
00279 hZvertexR[sec].back() -> Fill( pair.vertex().Z() );
00280 hZvertexR[ 12].back() -> Fill( pair.vertex().Z() );
00281
00282 if ( bin>= 0 ) hZggR[sec][bin] -> Fill( pair.zgg() );
00283 if ( bin>= 0 ) hZggR[ 12][bin] -> Fill( pair.zgg() );
00284 hZggR[sec].back() -> Fill( pair.zgg() );
00285 hZggR[ 12].back() -> Fill( pair.zgg() );
00286
00287 if ( bin>= 0 ) hPhiggR[sec][bin] -> Fill( pair.phigg() );
00288 if ( bin>= 0 ) hPhiggR[ 12][bin] -> Fill( pair.phigg() );
00289 hPhiggR[sec].back() -> Fill( pair.phigg() );
00290 hPhiggR[ 12].back() -> Fill( pair.phigg() );
00291
00292 if ( bin>= 0 ) hEnergyR[sec][bin] -> Fill( pair.energy() );
00293 if ( bin>= 0 ) hEnergyR[ 12][bin] -> Fill( pair.energy() );
00294 hEnergyR[sec].back() -> Fill( pair.energy() );
00295 hEnergyR[ 12].back() -> Fill( pair.energy() );
00296
00297
00298
00299
00301
00302 StEEmcPoint point1=pair.point(0);
00303 StEEmcPoint point2=pair.point(1);
00304
00305 TVector3 pos1 = point1.position();
00306 TVector3 pos2 = point2.position();
00307
00308 Float_t e1=point1.energy();
00309 Float_t e2=point2.energy();
00310
00311 TVector3 posp = ( e1 * pos1 + e2 * pos2 ) * ( 1.0/(e1+e2) );
00312
00313 hYXpair[sec] -> Fill( posp.X(), posp.Y() );
00314 hYXhigh[sec] -> Fill( pos1.X(), pos1.Y() );
00315 hYXlow[sec] -> Fill( pos2.X(), pos2.Y() );
00316 hE1E2[sec] -> Fill( e2, e1 );
00317
00318 hYXpair[ 12] -> Fill( posp.X(), posp.Y() );
00319 hYXhigh[ 12] -> Fill( pos1.X(), pos1.Y() );
00320 hYXlow[ 12] -> Fill( pos2.X(), pos2.Y() );
00321 hE1E2[ 12] -> Fill( e2, e1 );
00322
00323 }
00324
00325 }
00326
00327 }
00328
00329 return kStOK;
00330 }
00331
00332
00333
00334 Int_t StEEmcMixQAMaker::ptbin( StEEmcPair pair )
00335 {
00336 for ( UInt_t i=0;i<mBins.size()-1;i++ )
00337 {
00338 if ( pair.pt() > mBins[i] && pair.pt() <= mBins[i+1] ) return (Int_t)i;
00339 }
00340 return -1;
00341 }
00342
00343
00344 void StEEmcMixQAMaker::mixer(const Char_t *name, Float_t min, Float_t max)
00345 {
00346 mEEmixer=(StEEmcMixMaker *)GetMaker(name);
00347 assert(mEEmixer);
00348 mMin=min;
00349 mMax=max;
00350 assert(max>min && max>0.);
00351 }
00352
00353
00354 void StEEmcMixQAMaker::points(const Char_t *name)
00355 {
00356 mEEpoints=(StEEmcPointMaker *)GetMaker(name);
00357 assert(mEEpoints);
00358 }
00359
00360
00361 Bool_t StEEmcMixQAMaker::twoBodyCut( StEEmcPair pair )
00362 {
00363
00365
00366 Bool_t towers[720]; for (Int_t i=0;i<720;i++ ) towers[i]=false;
00367 StEEmcTower t1 = pair.point(0).tower(0);
00368 StEEmcTower t2 = pair.point(1).tower(0);
00369
00370 Float_t Etowers=0.;
00371 Etowers += t1.energy();
00372
00373 towers[ t1.index() ] = true;
00374 towers[ t2.index() ] = true;
00375
00376 for ( Int_t i=0;i<t1.numberOfNeighbors();i++ ) {
00377 StEEmcTower mytow=t1.neighbor(i);
00378 towers[ mytow.index() ] = true;
00379 Etowers += mytow.energy();
00380 }
00381 for ( Int_t i=0;i<t2.numberOfNeighbors();i++ ) {
00382 StEEmcTower mytow=t2.neighbor(i);
00383 if ( !towers[mytow.index()] ) Etowers += mytow.energy();
00384 towers[ mytow.index() ] = true;
00385 }
00386
00387
00388
00390
00393
00394 Int_t count = 0;
00395 for ( Int_t i=0;i<mEEpoints->numberOfPoints();i++ )
00396 {
00397 StEEmcPoint p=mEEpoints->point(i);
00398 StEEmcTower t=p.tower(0);
00399 if ( towers[ t.index() ] ) count++;
00400 }
00401
00402 Float_t Epoints = pair.energy();
00403
00404 return ( count <= maxPerCluster && Epoints > minTowerFrac * Etowers );
00405
00406 }