14 #include "../TJetNet.h"
15 #include "../doNormalization.C"
16 #include "Riostream.h"
17 #include "../TNetworkToHistoTool.h"
19 #include "../TTrainedNetwork.h"
32 return 1./(1.+
exp(-2*
x));
40 if(sizeX==-100){
return true;}
41 if(nParticles==0){
return true;}
42 if(nParticles!=1 && nParticles!=2 && nParticles!=3){
return true;}
52 bool skipSingle(
int nParticles,
int iClus,
int dilutionFactor){
62 if ((iClus %(dilutionFactor*
k) != 0) && (iClus % (dilutionFactor*
k) != 1))
84 if(useTrackEstimate &&
theta==0){
return true;}
94 "../TrkValidation.root",
113 int nodesSecondLayer,
114 int restartTrainingFrom,
115 bool useTrackEstimate,
116 int nPatternsPerUpdate,
118 double learningRateDecrease,
119 double learningRateMomentum)
126 gROOT->SetStyle(
"Plain");
128 cout <<
"starting with settings: " << endl;
129 cout <<
" nIterations: " << nIterations << endl;
130 cout <<
" dilutionFactor: " << dilutionFactor << endl;
131 cout <<
" nodesFirstLayer: " << nodesFirstLayer << endl;
132 cout <<
" nodesSecondLayer: " << nodesSecondLayer << endl;
137 TChain *myChain =
new TChain(
"Validation/NNinput");
140 if(!useTrackEstimate){
141 #include "../files.txt"
144 if(useTrackEstimate){
145 #include "../filesOnTrack.txt"
150 TChain* simu=myChain;
152 std::cout <<
" Training sample obtained... " << std::endl;
154 vector<int> *NN_sizeX;
155 vector<int> *NN_sizeY;
156 vector<vector<float> > *NN_matrixOfToT;
157 vector<vector<float> > *NN_vectorOfPitchesY;
158 vector<int> *NN_ClusterPixLayer;
159 vector<int> *NN_ClusterPixBarrelEC;
160 vector<float> *NN_phiBS;
161 vector<float> *NN_thetaBS;
162 vector<float> *NN_etaModule;
163 vector<bool> *NN_useTrackInfo;
164 vector<int> *NN_columnWeightedPosition;
165 vector<int> *NN_rowWeightedPosition;
166 vector<vector<float> > *NN_positionX;
167 vector<vector<float> > *NN_positionY;
168 vector<vector<float> > *NN_theta;
169 vector<vector<float> > *NN_phi;
174 TBranch *b_NN_matrixOfToT;
175 TBranch *b_NN_vectorOfPitchesY;
176 TBranch *b_NN_ClusterPixLayer;
177 TBranch *b_NN_ClusterPixBarrelEC;
179 TBranch *b_NN_thetaBS;
180 TBranch *b_NN_etaModule;
181 TBranch *b_NN_useTrackInfo;
182 TBranch *b_NN_columnWeightedPosition;
183 TBranch *b_NN_rowWeightedPosition;
184 TBranch *b_NN_positionX;
185 TBranch *b_NN_positionY;
194 NN_vectorOfPitchesY = 0;
195 NN_ClusterPixLayer = 0;
196 NN_ClusterPixBarrelEC = 0;
201 NN_columnWeightedPosition = 0;
202 NN_rowWeightedPosition = 0;
211 simu->SetMakeClass(1);
213 simu->SetBranchAddress(
"NN_sizeX", &NN_sizeX, &b_NN_sizeX);
214 simu->SetBranchAddress(
"NN_sizeY", &NN_sizeY, &b_NN_sizeY);
215 simu->SetBranchAddress(
"NN_matrixOfToT", &NN_matrixOfToT, &b_NN_matrixOfToT);
216 simu->SetBranchAddress(
"NN_vectorOfPitchesY", &NN_vectorOfPitchesY, &b_NN_vectorOfPitchesY);
217 simu->SetBranchAddress(
"NN_ClusterPixLayer", &NN_ClusterPixLayer, &b_NN_ClusterPixLayer);
218 simu->SetBranchAddress(
"NN_ClusterPixBarrelEC", &NN_ClusterPixBarrelEC, &b_NN_ClusterPixBarrelEC);
219 simu->SetBranchAddress(
"NN_phiBS", &NN_phiBS, &b_NN_phiBS);
220 simu->SetBranchAddress(
"NN_thetaBS", &NN_thetaBS, &b_NN_thetaBS);
221 simu->SetBranchAddress(
"NN_etaModule", &NN_etaModule, &b_NN_etaModule);
222 simu->SetBranchAddress(
"NN_useTrackInfo", &NN_useTrackInfo, &b_NN_useTrackInfo);
223 simu->SetBranchAddress(
"NN_columnWeightedPosition", &NN_columnWeightedPosition, &b_NN_columnWeightedPosition);
224 simu->SetBranchAddress(
"NN_rowWeightedPosition", &NN_rowWeightedPosition, &b_NN_rowWeightedPosition);
225 simu->SetBranchAddress(
"NN_positionX", &NN_positionX, &b_NN_positionX);
226 simu->SetBranchAddress(
"NN_positionY", &NN_positionY, &b_NN_positionY);
227 simu->SetBranchAddress(
"NN_theta", &NN_theta, &b_NN_theta);
228 simu->SetBranchAddress(
"NN_phi", &NN_phi, &b_NN_phi);
231 cout <<
"Branches set..." << endl;
234 TString filterTrain(
"Entry$%");
235 filterTrain+=dilutionFactor;
238 TString filterTest(
"Entry$%");
239 filterTest+=dilutionFactor;
245 cout <<
"Getting Max size " << endl;
251 cout <<
"First entry..." << endl;
258 for(
unsigned int clus =0; clus<NN_sizeX->size(); clus++ ){
260 sizeX = (*NN_sizeX)[clus];
261 sizeY = (*NN_sizeY)[clus];
267 cout <<
"Size obtained" << endl;
270 int numberinputs=sizeX*(sizeY+1)+4;
271 if (!useTrackEstimate)
274 numberinputs=sizeX*(sizeY+1)+5;
279 if (nodesSecondLayer!=0)
284 if (nodesSecondLayer!=0)
293 nneurons[0]=numberinputs;
295 nneurons[1]=nodesFirstLayer;
297 if (nodesSecondLayer!=0)
299 nneurons[2]=nodesSecondLayer;
308 float trainingError(0);
313 cout <<
" now providing training events " << endl;
315 Int_t numberTrainingEvents=0;
316 Int_t numberTestingEvents=0;
324 for (Int_t
i = 0;
i < simu->GetEntries();
i++) {
326 if (
i % 100000 == 0 ) {
327 std::cout <<
" Counting training / testing events in sample. Looping over event " <<
i << std::endl;
332 for(
unsigned int clus =0; clus<NN_sizeX->size(); clus++ ){
334 vector<float> *matrixOfToT=0;
335 vector<float> *vectorOfPitchesY=0;
340 Int_t ClusterPixLayer;
341 Int_t ClusterPixBarrelEC;
343 std::vector<float> * positionX=0;
344 std::vector<float> * positionY=0;
345 std::vector<float> * thetaTr=0;
346 std::vector<float> * phiTr=0;
348 sizeX = (*NN_sizeX)[clus];
349 sizeY = (*NN_sizeY)[clus];
351 positionX =&(*NN_positionX)[clus];
353 thetaTr = &(*NN_theta)[clus];
355 int nParticles = positionX->size();
359 for(
unsigned int P = 0;
P < positionX->size();
P++){
361 double theta = (*thetaTr)[
P];
367 if (
skipSingle(nParticles, iClus, dilutionFactor) )
continue;
371 if (iClus%dilutionFactor==0) numberTrainingEvents+=1;
372 if (iClus%dilutionFactor==1) numberTestingEvents+=1;
374 if (iClus%dilutionFactor==1 && nParticles==1 ) part_1++;
375 if (iClus%dilutionFactor==1 && nParticles==2 ) part_2++;
376 if (iClus%dilutionFactor==1 && nParticles==3 ) part_3++;
386 cout <<
" N. training events: " << numberTrainingEvents <<
387 " N. testing events: " << numberTestingEvents <<
388 " N. total events: " << iClus << endl;
391 cout <<
" 1 particle clusters: " << part_1 <<
" 2 particles clusters: " << part_2 <<
" 3 particles clusters: " << part_3 << endl;
393 cout <<
"now start to setup the network..." << endl;
395 TJetNet* jn =
new TJetNet( numberTestingEvents, numberTrainingEvents, nlayer, nneurons );
397 cout <<
" setting learning method... " << endl;
405 jn->
SetUpdatesPerEpoch( (
int)std::floor((
float)numberTrainingEvents/(
float)nPatternsPerUpdate) );
419 cout <<
" setting pattern for training events " << endl;
421 int trainSampleNumber=0;
422 int testSampleNumber=1;
424 cout <<
" copying over training events " << endl;
430 for (Int_t
i = 0;
i < simu->GetEntries();
i++) {
432 if (
i % 100000 == 0 ) {
433 std::cout <<
" Copying over training events. Looping over event " <<
i << std::endl;
438 for(
unsigned int clus =0; clus<NN_sizeX->size(); clus++ ){
440 vector<float> *matrixOfToT=0;
441 vector<float> *vectorOfPitchesY=0;
446 Int_t ClusterPixLayer;
447 Int_t ClusterPixBarrelEC;
449 std::vector<float> * positionX=0;
450 std::vector<float> * positionY=0;
451 std::vector<float> * thetaTr=0;
452 std::vector<float> * phiTr=0;
455 sizeX = (*NN_sizeX)[clus];
456 sizeY = (*NN_sizeY)[clus];
458 matrixOfToT=&(*NN_matrixOfToT)[clus];
459 vectorOfPitchesY=&(*NN_vectorOfPitchesY)[clus];
461 phiBS = (*NN_phiBS)[clus];
462 thetaBS =(*NN_thetaBS)[clus];
463 etaModule =(*NN_etaModule)[clus];
465 ClusterPixLayer=(*NN_ClusterPixLayer)[clus];
466 ClusterPixBarrelEC = (*NN_ClusterPixBarrelEC)[clus];
468 positionX =&(*NN_positionX)[clus];
469 thetaTr = &(*NN_theta)[clus];
470 phiTr = &(*NN_phi)[clus];
472 int nParticles = positionX->size();
476 for(
unsigned int P = 0;
P < positionX->size();
P++){
478 double theta = (*thetaTr)[
P];
479 double phi = (*phiTr)[
P];
486 if (
skipSingle(nParticles, iClus, dilutionFactor) )
continue;
489 if (matrixOfToT->size()!=sizeX*sizeY)
491 std::cout <<
" Event: " <<
i <<
" PROBLEM: size Y is: " << matrixOfToT->size() << std::endl;
492 throw std::runtime_error(
"Problem in number/trainNN.cxx");
496 for(
unsigned int ME =0; ME < matrixOfToT->size(); ME++){
501 if (counter1 == 0) std::cout <<
" element: " << ME <<
" ToT set to: " <<
norm_ToT((*matrixOfToT)[ME]) << std::endl;
507 for (
int s=0;
s<sizeY;
s++)
513 if (counter0 == 0) std::cout <<
" s: " <<
s <<
" pitch set to: " <<
norm_pitch((*vectorOfPitchesY)[
s]) << std::endl;
524 if (counter0 == 0) std::cout <<
" ClusterPixLayer " <<
norm_layerNumber(ClusterPixLayer) <<
" ClusterPixBarrelEC " <<
norm_layerType(ClusterPixBarrelEC) << std::endl;
526 if (useTrackEstimate)
548 if (counter0==0) std::cout <<
555 if (iClus%dilutionFactor==0) jn->
SetOutputTrainSet( counter0, 0, (nParticles==1 ? 1 : 0) );
556 if (iClus%dilutionFactor==0) jn->
SetOutputTrainSet( counter0, 1, (nParticles==2 ? 1 : 0) );
557 if (iClus%dilutionFactor==0) jn->
SetOutputTrainSet( counter0, 2, (nParticles>=3 ? 1 : 0) );
561 if (iClus%dilutionFactor==1) jn->
SetOutputTestSet( counter1, 0, (nParticles==1 ? 1 : 0) );
562 if (iClus%dilutionFactor==1) jn->
SetOutputTestSet( counter1, 1, (nParticles==2 ? 1 : 0) );
563 if (iClus%dilutionFactor==1) jn->
SetOutputTestSet( counter1, 2, (nParticles>=3 ? 1 : 0) );
568 if (iClus%dilutionFactor==0){counter0+=1;}
569 if (iClus%dilutionFactor==1){counter1+=1;}
577 cout << counter0 <<
" "<< numberTrainingEvents <<
" "<< iClus << endl;
579 if (counter0!=numberTrainingEvents)
581 cout <<
" counter up to: " << counter0 <<
" while events in training sample are " << numberTrainingEvents << endl;
586 if (counter1!=numberTestingEvents)
588 cout <<
" counter up to: " << counter1 <<
" while events in training sample are " << numberTestingEvents << endl;
594 if (restartTrainingFrom==0)
601 TString
name(
"Weights");
602 name+=restartTrainingFrom;
610 float minimumError=1e10;
611 int epochesWithRisingError=0;
612 int epochWithMinimum=0;
628 if (useTrackEstimate)
642 nameCronology+=
"/trainingCronology.txt";
646 cronology <<
"-------------SETTINGS----------------" << endl;
647 cronology <<
"Epochs: " << jn->
GetEpochs() << std::endl;
653 cronology <<
"Momentum: " << jn->
GetMomentum() << std::endl;
657 cronology <<
"-------------LAYOUT------------------" << endl;
658 cronology <<
"Input variables: " << jn->
GetInputDim() << endl;
659 cronology <<
"Output variables: " << jn->
GetOutputDim() << endl;
661 cronology <<
"Layout : ";
665 if (s<jn->GetHiddenLayerDim()+1) cronology <<
"-";
668 cronology <<
"--------------HISTORY-----------------" << endl;
669 cronology <<
"History of iterations: " << endl;
673 TH1F* histoTraining=
new TH1F(
"training",
"training",(
int)std::floor((
float)nIterations/10.+0.5),1,std::floor((
float)nIterations/10.+1.5));
674 TH1F* histoTesting=
new TH1F(
"testing",
"testing",(
int)std::floor((
float)nIterations/10.+0.5),1,std::floor((
float)nIterations/10.+1.5));
676 double maximumTrain=0;
677 double minimumTrain=1e10;
679 for(
int epoch=restartTrainingFrom+1;epoch<=nIterations;++epoch)
681 if (epoch!=restartTrainingFrom+1)
683 trainingError = jn->
Train();
686 if (epoch%10==0 || epoch==restartTrainingFrom+1)
689 cronology.open(nameCronology,ios_base::app);
693 if (trainingError>maximumTrain) maximumTrain=trainingError;
694 if (testError>maximumTrain) maximumTrain=testError;
695 if (trainingError<minimumTrain) minimumTrain=trainingError;
696 if (testError<minimumTrain) minimumTrain=testError;
699 histoTraining->Fill(epoch/10.,trainingError);
700 histoTesting->Fill(epoch/10.,testError);
702 if (testError<minimumError)
704 minimumError=testError;
705 epochesWithRisingError=0;
706 epochWithMinimum=epoch;
710 epochesWithRisingError+=10;
719 if (epochesWithRisingError>300)
721 if (trainingError<minimumError)
723 cout <<
" End of training. Minimum already on epoch: " << epochWithMinimum << endl;
724 cronology <<
" End of training. Minimum already on epoch: " << epochWithMinimum << endl;
729 cronology <<
"Epoch: [" << epoch <<
730 "] Error: " << trainingError <<
731 " Test: " << testError << endl;
733 cout <<
"Epoch: [" << epoch <<
734 "] Error: " << trainingError <<
735 " Test: " << testError << endl;
745 cout <<
"Writing File... " << endl;
746 TFile*
file=
new TFile(
name,
"recreate");
748 trainedNetwork->Write();
777 cout <<
" create Trained Network object..." << endl;
836 cout <<
" Now getting histograms from trainingResult" << endl;
837 cronology <<
" Now getting histograms from trainingResult" << endl;
841 cout <<
" From network to histo..." << endl;
844 cout <<
" From histo to network back..." << endl;
847 cout <<
" reading back " << endl;
888 if (epochWithMinimum!=0)
890 cronology <<
"Minimum stored from Epoch: " << epochWithMinimum << endl;
893 cronology <<
"Minimum not reached" << endl;
898 if (epochWithMinimum!=0)
903 name+=epochWithMinimum;
906 std::cout <<
" reading back from minimum " << endl;
909 TFile *_file0 =
new TFile(
name);
912 cout <<
" Reading back network with minimum" << endl;
919 trainedNetwork->Write();
924 cout <<
" -------------------- " << endl;
925 cout <<
" Writing OUTPUT histos " << endl;
928 histoFName+=
"/histoWeights.root";
930 TFile* fileHistos=
new TFile(histoFName,
"recreate");
933 std::vector<TH1*>::const_iterator histoBegin=myHistos.begin();
934 std::vector<TH1*>::const_iterator histoEnd=myHistos.end();
935 for (std::vector<TH1*>::const_iterator histoIter=histoBegin;
936 histoIter!=histoEnd;++histoIter)
938 (*histoIter)->Write();
951 cout <<
" using network at last iteration (minimum not reached..." << endl;
959 histoTName+=
"/trainingInfo.root";
961 TFile* histoFile=
new TFile(histoTName,
"recreate");
962 histoTraining->Write();
963 histoTesting->Write();
968 TCanvas* trainingCanvas=
new TCanvas(
"trainingCanvas",
"trainingCanvas");
969 histoTraining->SetLineColor(2);
970 histoTesting->SetLineColor(4);
972 histoTraining->GetYaxis()->SetRangeUser(minimumTrain,maximumTrain);
973 histoTraining->Draw(
"l");
974 histoTesting->Draw(
"lsame");
976 canvasName+=
"/trainingCurve.eps";
977 trainingCanvas->SaveAs(canvasName);
980 TCanvas* mlpa_canvas =
new TCanvas(
"jetnet_canvas",
"Network analysis");
981 mlpa_canvas->Divide(2,4);
993 TH1F *bg2 =
new TH1F(
"bg2h",
"NN output", 50, -.5, 1.5);
994 TH1F *
bg =
new TH1F(
"bgh",
"NN output", 50, -.5, 1.5);
995 TH1F *
sig =
new TH1F(
"sigh",
"NN output", 50, -.5, 1.5);
999 TH1F *bg2test =
new TH1F(
"bg2htest",
"NN output", 50, -.5, 1.5);
1000 TH1F *bgtest =
new TH1F(
"bghtest",
"NN output", 50, -.5, 1.5);
1001 TH1F *sigtest =
new TH1F(
"sightest",
"NN output", 50, -.5, 1.5);
1005 for (Int_t
i = 0;
i < simu->GetEntries();
i++) {
1007 if (
i % 100000 == 0 ) {
1008 std::cout <<
" First plot. Looping over event " <<
i << std::endl;
1016 for(
unsigned int clus =0; clus<NN_sizeX->size(); clus++ ){
1017 vector<float> *matrixOfToT=0;
1018 vector<float> *vectorOfPitchesY=0;
1023 Int_t ClusterPixLayer;
1024 Int_t ClusterPixBarrelEC;
1026 std::vector<float> * positionX=0;
1027 std::vector<float> * positionY=0;
1028 std::vector<float> * thetaTr=0;
1029 std::vector<float> * phiTr=0;
1033 sizeX = (*NN_sizeX)[clus];
1034 sizeY = (*NN_sizeY)[clus];
1036 matrixOfToT=&(*NN_matrixOfToT)[clus];
1037 vectorOfPitchesY=&(*NN_vectorOfPitchesY)[clus];
1039 phiBS = (*NN_phiBS)[clus];
1040 thetaBS =(*NN_thetaBS)[clus];
1041 etaModule =(*NN_etaModule)[clus];
1043 ClusterPixLayer=(*NN_ClusterPixLayer)[clus];
1044 ClusterPixBarrelEC = (*NN_ClusterPixBarrelEC)[clus];
1046 positionX =&(*NN_positionX)[clus];
1048 int nParticles = positionX->size();
1051 thetaTr = &(*NN_theta)[clus];
1052 phiTr = &(*NN_phi)[clus];
1057 for(
unsigned int P = 0;
P < positionX->size();
P++){
1060 double theta = (*thetaTr)[
P];
1061 double phi = (*phiTr)[
P];
1062 if (ClusterPixBarrelEC==2)
1070 if (
skipSingle(nParticles, iClus, dilutionFactor) )
continue;
1073 if (iClus%dilutionFactor==0||iClus%dilutionFactor==1){
1077 for(
unsigned int ME =0; ME < matrixOfToT->size(); ME++)
1082 for (
int s=0;
s<sizeY;
s++)
1091 if (useTrackEstimate)
1112 if (iClus%dilutionFactor==0)
1116 else if (iClus%dilutionFactor==1)
1123 if (iClus%dilutionFactor==0)
1127 else if (iClus%dilutionFactor==1)
1134 if (iClus%dilutionFactor==0)
1138 else if (iClus%dilutionFactor==1)
1155 for (Int_t
a=0;
a<
bg->GetNbinsX();
a++)
1157 if (
bg->GetBinContent(
a)>maximum)
1159 maximum=1.2*
bg->GetBinContent(
a);
1164 bg2->SetLineColor(kYellow);
1165 bg2->SetFillStyle(3008); bg2->SetFillColor(kYellow);
1166 bg->SetLineColor(kBlue);
1167 bg->SetFillStyle(3008);
bg->SetFillColor(kBlue);
1168 sig->SetLineColor(kRed);
1169 sig->SetFillStyle(3003);
sig->SetFillColor(kRed);
1175 bg2test->SetLineColor(kYellow);
1176 bg2test->SetFillStyle(3008); bg2test->SetFillColor(kYellow);
1177 bgtest->SetLineColor(kBlue);
1178 bgtest->SetFillStyle(3008); bgtest->SetFillColor(kBlue);
1179 sigtest->SetLineColor(kRed);
1180 sigtest->SetFillStyle(3003); sigtest->SetFillColor(kRed);
1181 bg2test->SetStats(0);
1182 bgtest->SetStats(0);
1183 sigtest->SetStats(0);
1188 bg->GetYaxis()->SetRangeUser(1,maximum);
1189 bgtest->GetYaxis()->SetRangeUser(1,maximum);
1196 TLegend *
legend =
new TLegend(.75, .80, .95, .95);
1197 legend->AddEntry(bg2,
"particles >=3");
1198 legend->AddEntry(
bg,
"particles = 2");
1206 bg2test->Draw(
"same");
1207 sigtest->Draw(
"same");
1209 TLegend *legendtest =
new TLegend(.75, .80, .95, .95);
1210 legendtest->AddEntry(bg2test,
"particles >=3");
1211 legendtest->AddEntry(bgtest,
"particles = 2");
1212 legendtest->AddEntry(sigtest,
"particles = 1");
1217 bg->DrawNormalized();
1218 bg2->DrawNormalized(
"same");
1219 sig->DrawNormalized(
"same");
1224 bgtest->DrawNormalized();
1225 bg2test->DrawNormalized(
"same");
1226 sigtest->DrawNormalized(
"same");
1238 TH1F *c_bg2 =
new TH1F(
"c_bg2h",
"NN output", 50, -.5, 1.5);
1239 TH1F *c_bg =
new TH1F(
"c_bgh",
"NN output", 50, -.5, 1.5);
1240 TH1F *c_sig =
new TH1F(
"c_sigh",
"NN output", 50, -.5, 1.5);
1242 TH1F *c_bg2test =
new TH1F(
"c_bg2htest",
"NN output", 50, -.5, 1.5);
1243 TH1F *c_bgtest =
new TH1F(
"c_bghtest",
"NN output", 50, -.5, 1.5);
1244 TH1F *c_sigtest =
new TH1F(
"c_sightest",
"NN output", 50, -.5, 1.5);
1248 for (Int_t
i = 0;
i < simu->GetEntries();
i++) {
1250 if (
i % 100000 == 0 ) {
1251 std::cout <<
" Second plot. Looping over event " <<
i << std::endl;
1257 for(
unsigned int clus =0; clus<NN_sizeX->size(); clus++ ){
1259 vector<float> *matrixOfToT=0;
1260 vector<float> *vectorOfPitchesY=0;
1265 Int_t ClusterPixLayer;
1266 Int_t ClusterPixBarrelEC;
1268 std::vector<float> * positionX=0;
1269 std::vector<float> * positionY=0;
1270 std::vector<float> * thetaTr=0;
1271 std::vector<float> * phiTr=0;
1274 sizeX = (*NN_sizeX)[clus];
1275 sizeY = (*NN_sizeY)[clus];
1277 if(sizeX==-100)
continue;
1279 matrixOfToT=&(*NN_matrixOfToT)[clus];
1280 vectorOfPitchesY=&(*NN_vectorOfPitchesY)[clus];
1282 phiBS = (*NN_phiBS)[clus];
1283 thetaBS =(*NN_thetaBS)[clus];
1284 etaModule =(*NN_etaModule)[clus];
1286 ClusterPixLayer=(*NN_ClusterPixLayer)[clus];
1287 ClusterPixBarrelEC = (*NN_ClusterPixBarrelEC)[clus];
1289 positionX =&(*NN_positionX)[clus];
1291 int nParticles = positionX->size();
1292 if(nParticles==0)
continue;
1294 thetaTr = &(*NN_theta)[clus];
1295 phiTr = &(*NN_phi)[clus];
1302 for(
unsigned int P = 0;
P < positionX->size();
P++){
1305 double theta = (*thetaTr)[
P];
1306 double phi = (*phiTr)[
P];
1307 if (ClusterPixBarrelEC==2)
1315 if (
skipSingle(nParticles, iClus, dilutionFactor) )
continue;
1319 if (iClus%dilutionFactor==0||iClus%dilutionFactor==1){
1323 for(
unsigned int ME =0; ME < matrixOfToT->size(); ME++)
1331 for (
int s=0;
s<sizeY;
s++)
1339 if (useTrackEstimate)
1363 if (iClus%dilutionFactor==0)
1365 c_sig->Fill(discr,
weight);
1367 else if (iClus%dilutionFactor==1)
1369 c_sigtest->Fill(discr,
weight);
1374 if (iClus%dilutionFactor==0)
1376 c_bg->Fill(discr,
weight);
1378 else if (iClus%dilutionFactor==1)
1380 c_bgtest->Fill(discr,
weight);
1385 if (iClus%dilutionFactor==0)
1387 c_bg2->Fill(discr,
weight);
1389 else if (iClus%dilutionFactor==1)
1391 c_bg2test->Fill(discr,
weight);
1403 for (Int_t
a=0;
a<c_bg->GetNbinsX();
a++)
1405 if (c_bg->GetBinContent(
a)>maximum)
1407 maximum=1.2*c_bg->GetBinContent(
a);
1410 c_bg2->SetLineColor(kYellow);
1411 c_bg2->SetFillStyle(3008); c_bg2->SetFillColor(kYellow);
1412 c_bg->SetLineColor(kBlue);
1413 c_bg->SetFillStyle(3008); c_bg->SetFillColor(kBlue);
1414 c_sig->SetLineColor(kRed);
1415 c_sig->SetFillStyle(3003); c_sig->SetFillColor(kRed);
1420 c_bg2test->SetLineColor(kYellow);
1421 c_bg2test->SetFillStyle(3008); c_bg2test->SetFillColor(kYellow);
1422 c_bgtest->SetLineColor(kBlue);
1423 c_bgtest->SetFillStyle(3008); c_bgtest->SetFillColor(kBlue);
1424 c_sigtest->SetLineColor(kRed);
1425 c_sigtest->SetFillStyle(3003); c_sigtest->SetFillColor(kRed);
1426 c_bg2test->SetStats(0);
1427 c_bgtest->SetStats(0);
1428 c_sigtest->SetStats(0);
1434 c_bg->GetYaxis()->SetRangeUser(1,maximum);
1435 c_bgtest->GetYaxis()->SetRangeUser(1,maximum);
1438 c_bg2->Draw(
"same");
1439 c_sig->Draw(
"same");
1441 TLegend *legend2 =
new TLegend(.75, .80, .95, .95);
1442 legend2->AddEntry(c_bg2,
"particles >=3");
1443 legend2->AddEntry(c_bg,
"particles = 2");
1444 legend2->AddEntry(c_sig,
"particles = 1");
1451 c_bg2test->Draw(
"same");
1452 c_sigtest->Draw(
"same");
1454 TLegend *legend2test =
new TLegend(.75, .80, .95, .95);
1455 legend2test->AddEntry(c_bg2test,
"particles >=3");
1456 legend2test->AddEntry(c_bgtest,
"particles = 2");
1457 legend2test->AddEntry(c_sigtest,
"particles = 1");
1458 legend2test->Draw();
1462 c_bg->DrawNormalized();
1463 c_bg2->DrawNormalized(
"same");
1464 c_sig->DrawNormalized(
"same");
1469 c_bgtest->DrawNormalized();
1470 c_bg2test->DrawNormalized(
"same");
1471 c_sigtest->DrawNormalized(
"same");
1472 legend2test->Draw();
1478 resultName+=
"/result.eps";
1479 mlpa_canvas->SaveAs(resultName);