//This macro is used to study (and calibrate) the radial dependence of the light signal. Tracks that originate at the center of the TPC are brighter than those on the side and this needs to be accounted for in energy reconstruction.
//The neutron calibration is very useful for this purpose as the tracks are quite short, which makes the radial position of the track well defined.
void DCTPCTree::Loop()
{

TStopwatch timer;
  gROOT->SetStyle("Plain");
  gStyle->SetEndErrorSize(3);
  gStyle->SetPalette(1,0);
  gStyle->SetLineWidth(2);
  gStyle->SetHistLineWidth(2);
//   gStyle->SetOptStat(kFALSE);
  gStyle->SetOptFit(kTRUE);
  TH1::AddDirectory(false);
  
  TFile *outtree = new TFile("$LittleDCTPC_neutron_calibration_input");
  TTree *dctreepc = (TTree*)outtree->Get("dctpc_eventinfo");
  DCTPCTree aStep(dctreepc);
  
  TH2D *hist_radialE=new TH2D("","",30,0,150,30,0,2.0);
  TH2D *hist_energy=new TH2D("E", "E", 100, 0, 1000, 100, 0, 1000);

double rstart=0.;
double rend=0.;

  Long64_t nentries = dctreepc->GetEntries();
  cout << "Number of Entries: " << nentries << endl;
 
  for (int event = 0; event<nentries; event++)
    {
      aStep.GetEntry(event); 
      
      if(event%10000==0)
	  cout<<((double)event/(double)nentries)*100.<<"%"<<endl;	

double rr=(pow(aStep.Track_x_pix,2)+pow(aStep.Track_y_pix,2))*pow(MMPERPIXEL/10.,2);

 //these cuts are meant to isolate short, fully contained tracks not originating from the rings. We want short tracks so that the radial position is well defined.
     if (aStep.BurnIn==0 && 
     aStep.Edge==0  && 
     (aStep.Etrack_kev-aStep.Etrig_kev)<50. && 
     aStep.Track_range_pix<80. )	
	{
	
     //this cut removes the events that are associated with a very small waveform, probably due to noise
	 if(abs((aStep.Etrig_kev)-(aStep.Etrack_kev))>1000. && (aStep.Etrig_kev)<2000.)
	 continue;

	 hist_radialE->Fill(rr,(aStep.Etrack_kev)/(aStep.Etrig_kev));	 	
	 hist_energy->Fill(aStep.Etrack_kev,aStep.Etrig_kev);	
	 	  
	 }
    
     }
 
new TCanvas;
hist_radialE->Draw("COLZ");  
  
TProfile *prof = hist_radialE->ProfileX();
new TCanvas;
prof->Draw();  


//perform a simple fit that can be used for calibrating energy as a function of radius  
TF1 *f1 = new TF1("f1","[0]/([1] +x)^[2]",0,500);
prof->Fit("f1");
  
cout<<"Param 0: "<<f1->GetParameter(0)<<endl;
cout<<"Param 1: "<<f1->GetParameter(1)<<endl;
cout<<"Param 2: "<<f1->GetParameter(2)<<endl;

//this is the original fit used in the DCTPC NIM paper. It is interesting to compare the two fits. 
TF1 *f2 = new TF1("f2","1./(pow(1+ x/(16.123*16.123),3.5857/2 ))",0,500);
f2->SetLineColor(2);
f2->Draw("SAME");

new TCanvas; 
f2->Draw();
f1->Draw("SAME");

new TCanvas;
hist_energy->Draw("COLZ");
  
}
//This macro is used to study (and calibrate) the radial dependence of the light signal. Tracks that originate at the center of the TPC are brighter than those on the side and this needs to be accounted for in energy reconstruction.
void DCTPCTree::Loop()
{

TStopwatch timer;
  gROOT->SetStyle("Plain");
  gStyle->SetEndErrorSize(3);
  gStyle->SetPalette(1,0);
  gStyle->SetLineWidth(2);
  gStyle->SetHistLineWidth(2);
  gStyle->SetOptStat(kFALSE);
  gStyle->SetOptFit(kTRUE);
  TH1::AddDirectory(false);
  
  TFile *outtree = new TFile("$BigDCTPC_calibration_input");
  TTree *dctreepc = (TTree*)outtree->Get("dctpc_eventinfo");
  DCTPCTree aStep(dctreepc);
  
  TH2D *hist_radialE=new TH2D("","",30,0,600,30,0,2.);
  TH2D *hist_energy=new TH2D("E", "E", 100, 0, 1000, 100, 0, 1000);
  TH2D *hist_energy2=new TH2D("E", "E", 100, 0, 1000, 100, 0, 1000);
  
double recalibmesh = 1.;
double recalibCCD = 1.;
double recalibanode = 1.;
double rstart=0.;
double rend=0.;

  Long64_t nentries = dctreepc->GetEntries();
  cout << "Number of Entries: " << nentries << endl;
 
  for (int event = 0; event<nentries; event++)
    {
      aStep.GetEntry(event); 
      
      if(event%10000==0)
	  cout<<((double)event/(double)nentries)*100.<<"%"<<endl;	

double rr=(pow(aStep.Track_x_pix,2)+pow(aStep.Track_y_pix,2))*pow(MMPERPIXEL/10.,2);

 //these cuts are meant to isolate short, fully contained tracks not originating from the rings. We want short tracks so that the radial position is well defined.
     if (
     aStep.Edge==0  && 
     aStep.Ntrig <=2 &&
TMath::Abs((aStep.Etrig_kev-aStep.Etrack_kev)/(aStep.Etrig_kev+aStep.Etrack_kev))<0.4 &&
TMath::Abs((aStep.Etrig_kev-aStep.Emesh_kev)/(aStep.Etrig_kev+aStep.Emesh_kev))<0.1 &&
     aStep.Track_range_pix<80.
     )	
	{
 

	 hist_radialE->Fill(rr,(aStep.Etrack_kev)/(aStep.Etrig_kev));
hist_energy->Fill(aStep.Etrack_kev,aStep.Etrig_kev);  
hist_energy2->Fill(aStep.Etrig_kev,aStep.Emesh_kev);
	 
	 }
    
     }
 
new TCanvas;
hist_radialE->SetXTitle("radius (pixels)");
hist_radialE->SetYTitle("E_{CCD}/E_{anode}");
hist_radialE->Draw("COLZ");  
  
TProfile *prof = hist_radialE->ProfileX();
new TCanvas;

prof->SetYTitle("E_{CCD}/E_{anode}");
prof->Draw();  


//perform a simple fit that can be used for calibrating energy as a function fo radius  
TF1 *f1 = new TF1("f1","[0]/([1] +x)^[2]",0,440);
prof->Fit("f1","R");
  
cout<<"Param 0: "<<f1->GetParameter(0)<<endl;
cout<<"Param 1: "<<f1->GetParameter(1)<<endl;
cout<<"Param 2: "<<f1->GetParameter(2)<<endl;

//6.23665/pow(141.035+r,0.360402);

TF1 *f2 = new TF1("f2","7.56874/(146.405+x)^0.388667",0,440); 
  
f2->Draw("SAME");
new TCanvas;
hist_energy->Draw("COLZ"); 

new TCanvas;
hist_energy2->Draw("COLZ");   
  
}
Ejemplo n.º 3
0
void cParamIntrinsequeFormel::UpdateCamGrid( double aTol)
{
   if (UseAFocal()  &&  (! AFocalAcceptNoDist))
      return;
   bool aLastFiged = mFiged;
   mFiged = AllParamIsFiged() ;
   // Si rien n'a change
   if (aLastFiged == mFiged)
      return;

   // On passe de fige a mobile, donc plus de grille
   if (aLastFiged)
   {
        delete mCamGrid;
        mCamGrid =0;
        return;
   }

   //   On se fige
   //
 
      CamStenope * aCS = CurPIF();

      Pt2di aRab(20,20);
      Pt2di aStep(10,10);
      double aRabR = 0;
      Pt2di aSz = aCS->Sz();

      double aR = euclid(aSz)/2.0;
      if (aCS->HasRayonUtile())
         aR = aCS->RayonUtile();

// std::cout << "iuytml RAY = " << aR << " SZR " <<  euclid(aSz)/2.0 << "\n";

      mCamGrid = cCamStenopeGrid::Alloc(aR+aRabR,*aCS,Pt2dr(aStep),true,true);
      if (mCamGrid)
      {

          mRayonGrid = 1e20;

// std::cout << "iuytml END CGID  \n";

           double aEcMax =0;
           for (int aKx=100 ; aKx< aCS->Sz().x ; aKx += 200)
           {
               for (int aKy=100 ; aKy< aCS->Sz().y ; aKy += 200)
               {
                   Pt2dr aP(aKx,aKy);
                   // std::cout << "IZU " << mCamGrid->IsInZoneUtile(aP) << " " << aP << "\n";
                   if (mCamGrid->IsInZoneUtile(aP))
                   {
                      // UVGCC4.6 double aEps=1e-5;

                       Pt3dr aRay = aCS->F2toDirRayonL3(aP);
                       // UVGCC4.6 Pt3dr aRayG = mCamGrid->F2toDirRayonL3(aP);


                       // UVGCC4.6 Pt3dr  aRayX = aRay + Pt3dr(aEps,0,0);
                       // UVGCC4.6 Pt3dr  aRayY = aRay + Pt3dr(0,aEps,0);

                       Pt2dr aP1 = aCS->L3toF2(aRay);
                       Pt2dr aPG = mCamGrid->L3toF2(aRay);


                       // UVGCC4.6 Pt2dr aDx = (mCamGrid->L3toF2(aRayX)-aPG)/aEps;
                       // UVGCC4.6 Pt2dr aDy = (mCamGrid->L3toF2(aRayY)-aPG)/aEps;


                       Pt2dr aDGX,aDGY;
                       // UVGCC4.6 Pt2dr aPG2 = mCamGrid->L2toF2AndDer(Pt2dr(aRay.x,aRay.y),aDGX,aDGY);

                // std::cout << aPG << aDx << aDy << "\n";
                // std::cout <<  "    " << aPG2 << aDGX << aDGY << "\n";

                       double aDist = euclid(aP1,aPG);
                       if ( aDist >aTol)
                          mRayonGrid = ElMin(mRayonGrid,euclid(aP,aSz/2.0));
                       aEcMax = ElMax(aDist,aEcMax);
                    }
               }
           }
/*

        std::cout << "GetC ------------RTOl------------ " << mRayonGrid   << " -EcMax " << aEcMax << "\n"; 
         getchar();
*/

    }


}
Ejemplo n.º 4
0
void DCTPC_runtree::Loop()
{

TStopwatch timer;
gROOT->SetStyle("Plain");
gStyle->SetEndErrorSize(3);
gStyle->SetPalette(1,0);
gStyle->SetLineWidth(2);
gStyle->SetHistLineWidth(2);
gStyle->SetOptStat(kFALSE);
gStyle->SetOptFit(kFALSE);
TH1::AddDirectory(false);

TH2D *hist_time=new TH2D("","",10000,1391000000,1410000000,1000,0,1000);
TH2D *hist_time2=new TH2D("","",10000,900,15200,1000,0,1000);
TFile *outtree = new TFile("$BigDCTPC_physics_input");
TTree *dctreepc = (TTree*)outtree->Get("dctpc_runinfo");

DCTPC_runtree aStep(dctreepc);

Long64_t nentries = dctreepc->GetEntries();
cout << "Number of Entries: " << nentries << endl;

int exposure7=0;
int exposure8=0;
int exposure9=0;
int exposure10=0;
int exposure11=0;
int exposure12=0;
int exposure13=0;
int exposure14=0;
int exposure15=0;
int exposure16=0;

for (int event = 0; event<nentries; event++)
{
aStep.GetEntry(event);

 
 if(aStep.RunNum>=955 && aStep.RunNum<=1645)
 exposure7+=aStep.Exposure_sec;
 
 if(aStep.RunNum>=1646 && aStep.RunNum<=2205)
 exposure8+=aStep.Exposure_sec; 
 
 if(aStep.RunNum>=2206 && aStep.RunNum<=2648)
 exposure9+=aStep.Exposure_sec;

 if(aStep.RunNum>=2650 && aStep.RunNum<=3868)
 exposure10+=aStep.Exposure_sec;
 
 if(aStep.RunNum>=3876 & aStep.RunNum<=5789)
 exposure11+=aStep.Exposure_sec;   
 
 if(aStep.RunNum>=5792&&aStep.RunNum<=7520)
 exposure12+=aStep.Exposure_sec;
 
 if(aStep.RunNum>=7530&&aStep.RunNum<=9143)
 exposure13+=aStep.Exposure_sec;
 
 if(aStep.RunNum>=9147&&aStep.RunNum<=12833)
 exposure14+=aStep.Exposure_sec;
 
 if(aStep.RunNum>=12837&&aStep.RunNum<=13311)
 exposure15+=aStep.Exposure_sec;
 
 if(aStep.RunNum>=13315)
 exposure16+=aStep.Exposure_sec;
 
hist_time->Fill(aStep.Time_startofrun_sec,aStep.Exposure_sec); 
hist_time2->Fill(aStep.RunNum,aStep.Exposure_sec); 
}

cout<<"Sequence 7 has an exposure of "<<exposure7<<" seconds"<<endl; 
cout<<"Sequence 8 has an exposure of "<<exposure8<<" seconds"<<endl;
cout<<"Sequence 9 has an exposure of "<<exposure9<<" seconds"<<endl;
cout<<"Sequence 10 has an exposure of "<<exposure10<<" seconds"<<endl;
cout<<"Sequence 11 has an exposure of "<<exposure11<<" seconds"<<endl;
cout<<"Sequence 12 has an exposure of "<<exposure12<<" seconds"<<endl;
cout<<"Sequence 13 has an exposure of "<<exposure13<<" seconds"<<endl;
cout<<"Sequence 14 has an exposure of "<<exposure14<<" seconds"<<endl;
cout<<"Sequence 15 has an exposure of "<<exposure15<<" seconds"<<endl;
cout<<"Sequence 16 has an exposure of "<<exposure16<<" seconds"<<endl;

new TCanvas;
hist_time->SetMarkerStyle(7);
hist_time->SetTitle("Exposure for each run");
hist_time->SetXTitle("Unix time");
hist_time->SetYTitle("Exposure (seconds)");
hist_time->Draw();


new TCanvas;
hist_time2->SetMarkerStyle(7);
hist_time2->SetTitle("Exposure for each run");
hist_time2->SetXTitle("Unix time");
hist_time2->SetYTitle("Exposure (seconds)");
hist_time2->Draw();

}