Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:29:11

0001 //________________________________________________________________________________________
0002 int plot( TString fileName = "px-00.txt", bool redraw = true )
0003 {
0004   if ( redraw ) {
0005    TCanvas* myCanvas = new TCanvas("myCanvas","Canvas",10,10,800,600);
0006    myCanvas->cd(1);
0007   }
0008 
0009   TTree* tree = new TTree("tree","Cherenkov photons");
0010   std::cout << tree->ReadFile(fileName,"px/D:py:pz:x:y:z") 
0011             << " lines read from " << fileName << std::endl;
0012   tree->Draw("x");
0013   
0014   return 0;
0015 }
0016 
0017 
0018 //________________________________________________________________________________________
0019 int trackAngle( TString fileName = "simevent.root" )
0020 {
0021 
0022   TFile* f = new TFile(fileName);
0023   TTree* events = f->Get("Events");
0024 
0025   events->SetAlias("position","SimTracks_g4SimHits__CaloTest.obj.tkposition.fCoordinates");
0026   events->SetAlias("momentum","SimTracks_g4SimHits__CaloTest.obj.theMomentum.fCoordinates");
0027 
0028   TCanvas* myCanvas = new TCanvas("myCanvas","Canvas",10,10,600,900);
0029   myCanvas->Divide(1,2);
0030   
0031   myCanvas->cd(1);
0032   events->Draw("position.fY");
0033   myCanvas->cd(2);
0034   events->Draw("TMath::ATan(momentum.fX/momentum.fY)*180/TMath::Pi()");
0035 
0036   return 0;
0037 }
0038 
0039 
0040 //________________________________________________________________________________________
0041 int getAngleParams( double angle )
0042 {
0043 
0044   double meanY = 0.9; // Y position of gun - (width crystal)/2
0045 
0046   double radAngle = angle*TMath::Pi()/180.;
0047 
0048   double meanX = -meanY*TMath::Tan( radAngle );
0049   
0050   double phi = TMath::PiOver2()-radAngle;
0051 
0052   std::cout << "    replace VtxSmeared.MeanX = " << meanX << std::endl;
0053   cout.precision(16);
0054   std::cout << "    replace FlatRandomEGunProducer.PGunParameters.MinPhi = " << phi << std::endl;
0055   std::cout << "    replace FlatRandomEGunProducer.PGunParameters.MaxPhi = " << phi << std::endl;
0056 
0057   return 0;
0058 
0059 }
0060 
0061 //________________________________________________________________________________________
0062 int plotAll() {
0063                                                                         
0064   gStyle->SetOptStat(0);
0065   gStyle->SetOptDate(0);
0066   gStyle->SetOptTitle(0);
0067   TCanvas* myCanvas = new TCanvas("myCanvas","Canvas",10,10,800,800);
0068   myCanvas->Divide(2,5);
0069   TH2F* range = new TH2F("range","Cherenkov photons ; x [mm]; y [mm]",2,-50,50,2,-12,12);
0070   //TH2F* range = new TH2F("range","Cherenkov photons ; #(photons)/step",2,0,300,2,0,300);
0071   range->GetXaxis()->SetTitleSize(0.09);
0072   range->GetXaxis()->SetTitleOffset(-0.5);
0073   range->GetYaxis()->SetTitleSize(0.09);
0074   range->GetYaxis()->SetTitleOffset(0.5);
0075 
0076   const int nfiles = 9;
0077   TString fileRoot("output");
0078   char fileName[50];
0079 
0080   // Draw angle = 0 twice
0081   TLatex* t = new TLatex();
0082   char angle[20];
0083   TFile* file = new TFile("output-1.root");
0084   TTree* tree0 = file->Get("g4SimHits/tree");
0085   for ( int i=1; i<=2; ++i ) {
0086     myCanvas->cd(i);
0087     range->Draw();
0088     tree0->Draw("y:x","","same");
0089     //tree0->Draw("nphotons","");
0090     t->DrawLatex(-40,-10,"angle = 0");
0091   }
0092   
0093   // Draw other angles
0094   for ( int ifile = 1; ifile<nfiles; ++ifile ) {
0095 
0096     int ican = 2*ifile+1-(ifile/5)*7; // Sorry for that...
0097     std::cout << ican << std::endl;
0098     myCanvas->cd( ican );
0099     sprintf(fileName,"%s-%1d.root",fileRoot.Data(),ifile+1);
0100     TFile* file = new TFile(fileName);
0101     TTree* tree = file->Get("g4SimHits/tree");
0102     range->Draw();
0103     tree->Draw("y:x","","same");
0104 //     tree->Draw("nphotons","");
0105     if ( ifile<5) sprintf(angle,"angle = %02d",(ifile*10));
0106     else sprintf(angle,"angle = %02d",-((ifile-4)*10));
0107     t->DrawLatex(-40,-10,angle);
0108   }
0109 
0110 
0111   return 0;
0112 
0113 }