Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:51

0001 void MacroTest()
0002 {
0003   ifstream myStream1("/tmp/trentad/OutBatch/EffGeneralBatch.dat", ios::in);
0004   ifstream myStream2("/tmp/trentad/OutBatch/NoiseGeneralBatch.dat", ios::in);
0005   ifstream myStream3("/tmp/trentad/OutBatch/EffRollBatch_637567005.dat", ios::in);
0006   ifstream myStream4("/tmp/trentad/OutBatch/EffRollBatch_637632541.dat", ios::in);
0007 
0008   TFile* output = new TFile("/tmp/trentad/OutBatch/histoTest_EffNoiseBatch.root","RECREATE");
0009 
0010   //---------------------- General -----------------------------------------
0011 
0012   TH1F* hclsGen = new TH1F("Cls Gen", "Cls Gen", 10, 0.5,10.5);
0013   TH1F* hBxGen = new TH1F("Bx Gen", "Bx Gen", 15, -7.5,7.5);
0014   TH1F* hBxGenEff = new TH1F("Bx GenEff", "Bx GenEff", 15, -7.5,7.5);
0015   TH1F* hProfileGen = new TH1F("Profile Gen", "Profile Gen", 100, 0.5,100.5);
0016   TH1F* hPosGenCls1 = new TH1F("Pos Gen cls1", "Pos Gen cls1", 20, 0.,1.);
0017   TH1F* hPosGenCls2 = new TH1F("Pos Gen cls2", "Pos Gen cls2", 20, 0.,1.);
0018   TH1F* hPosGenCls3 = new TH1F("Pos Gen cls3", "Pos Gen cls3", 20, 0.,1.);
0019 
0020   //---------------------- Roll---------------------------------------------
0021 
0022   TH1F* hclsRoll = new TH1F("Cls Roll", "Cls Roll", 10, 0.5,10.5);
0023   TH1F* hBxRoll = new TH1F("Bx Roll", "Bx Roll", 15, -7.5,7.5);
0024   TH1F* hProfileRoll1 = new TH1F("Profile Roll 1", "Profile Roll 1", 100, 0.5,100.5);
0025   TH1F* hProfileRoll2 = new TH1F("Profile Roll 2", "Profile Roll 2", 100, 0.5,100.5);
0026 
0027   TH1F* hProfileEff = new TH1F("Profile Eff", "Profile Eff", 100, 0.5,100.5);
0028 
0029   TH1F* hPosRollCls1 = new TH1F("Pos Roll cls1", "Pos Roll cls1", 20, 0.,1.);
0030   TH1F* hPosRollCls2 = new TH1F("Pos Roll cls2", "Pos Roll cls2", 20, 0.,1.);
0031   TH1F* hPosRollCls3 = new TH1F("Pos Roll cls3", "Pos Roll cls3", 20, 0.,1.);
0032 
0033   //------------------------------------------------------------------------
0034 
0035   int strip= 0 , bx = 0, cls = 0;
0036   float posX = 0.;
0037   int counter = 0;
0038 
0039   while(!myStream1.eof()){
0040        if(counter == 6400000) break;
0041 
0042     myStream1>>strip>>bx>>cls>>posX;
0043     std::cout<<counter<<"  "<<strip<<"  "<<bx<<"  "<<cls<<"  "<<posX<<std::endl;
0044     if(strip > 100) continue;
0045     hclsGen->Fill(cls);
0046     hBxGen->Fill(bx);
0047     hBxGenEff->Fill(bx);
0048     hProfileGen->Fill(strip);
0049 
0050     if(cls == 1) hPosGenCls1->Fill(posX);
0051     if(cls == 2) hPosGenCls2->Fill(posX);
0052     if(cls == 3) hPosGenCls3->Fill(posX);
0053     counter++;
0054   }
0055 
0056   counter = 0;
0057   while(!myStream2.eof()){
0058     if(counter == 6400000) break;
0059     myStream2>>strip>>bx;
0060 
0061     if(strip > 100) continue;
0062     hProfileGen->Fill(strip);
0063     hBxGen->Fill(bx);
0064     counter++;
0065   }
0066 
0067   counter = 0;
0068   while(!myStream3.eof()){
0069     if(counter == 6400000) break;
0070     myStream3>>strip>>bx>>cls>>posX;
0071     if(strip > 100) continue;
0072     hclsRoll->Fill(cls);
0073     hBxRoll->Fill(bx);
0074     hProfileRoll1->Fill(strip);
0075 
0076     if(cls == 1) hPosRollCls1->Fill(posX);
0077     if(cls == 2) hPosRollCls2->Fill(posX);
0078     if(cls == 3) hPosRollCls3->Fill(posX);
0079     counter++;
0080   }
0081 
0082   counter = 0;
0083   while(!myStream4.eof()){
0084     if(counter == 6400000) break;
0085     myStream4>>strip>>bx>>cls>>posX;
0086     if(strip > 100) continue;
0087     hProfileRoll2->Fill(strip);
0088     //    hBxRoll->Fill(bx);
0089     counter++;
0090   }
0091 
0092   for(int i = 1; i <= 100; ++i){
0093     float raf1 = hProfileRoll2->GetBinContent(i);
0094     float raf2 = hProfileRoll1->GetBinContent(i);
0095     if(raf1 > 0){
0096       float eff = raf2/raf1;
0097       if(eff<=1){
0098     float err = sqrt(eff(1-eff)/raf1);
0099     hProfileEff->SetBinContent(i,eff);
0100     hProfileEff->SetBinError(i,err);
0101       }
0102     }
0103   }
0104 
0105   output->Write();
0106 
0107 }