Exemple #1
0
int createDefaultConfig()
{
    /*
     * Create GBA folder for configuration and ROMS
     */
    if (false == check_mkdir("/accounts/1000/shared/misc/roms",0777) )              return -1;
    if (false == check_mkdir("/accounts/1000/shared/misc/gbaemu", 0777) )           return -1;
    if (false == check_mkdir("/accounts/1000/shared/misc/gbaemu/savegames", 0777) ) return -1;
    if (false == check_mkdir("/accounts/1000/shared/misc/roms/gba",0777) )          return -1;

    /*
     * If config file is not is misc/gbaemu, copy the default one
     */
    ifstream ifile2("/accounts/1000/shared/misc/gbaemu/gpsp.cfg");
    if(!ifile2){
        ifstream f11("app/native/gpsp.cfg", fstream::binary);
        ofstream f22("/accounts/1000/shared/misc/gbaemu/gpsp.cfg", fstream::trunc|fstream::binary);
        f22 << f11.rdbuf();
        f11.close();
        f22.close();
    } else {
        ifile2.close();
    }

    /*
     * Copy game_config.txt to savegames folder if not there
     */
    ifstream ifile3("/accounts/1000/shared/misc/gbaemu/savegames/game_config.txt");
    if(!ifile3){
        ifstream f11("app/native/game_config.txt", fstream::binary);
        ofstream f22("/accounts/1000/shared/misc/gbaemu/savegames/game_config.txt", fstream::trunc|fstream::binary);
        f22 << f11.rdbuf();
        f11.close();
        f22.close();
    } else {
        ifile3.close();
    }

    return 0;
}
void analysis_125CF4_bigdctpc_alpha(int firstrun, int lastrun){//inclusive 
  
  //It is necessary to employ calibration constants in creating the reduced file because we only associate one waveform to one CCD track per event. The matching is based off of energy reconstruction agreement. 	

  double lightCalib = 0.48;
  double anodeCalib= 23.2;
  double meshCalib = 37.8;
  const int maxentries=100;
  
  int BATCH=0;//0 if running interactively, 1 if running batch
  
  gSystem->Load("libMaxCam");
  gSystem->Load("libWaveformTools.so");

  DmtpcSkimDataset d;
  DmtpcSkimDataset d2;
  std::stringstream sstm;
  std::stringstream sstmxxx;
  int passTrack = 0;
  int passTrig = 0;
  int passAll = 0;
  int ntotalTrack = 0;
  int ntrack=0;
  int ntrig=0;
  int ntotalTrig = 0;
  int lastSpark = -1; 
  int cutnum=0;
  int spark, edge, burnin, last_spark, runnum, runnum2, evnum, neighbors, Tracknpixel;
  double image_mean=0.;
  double image_rms=0.;
  int pixels_killed=0;
  int seqnum=-1;
  int seqnum2=-1;
  int seqcounter=0;
  int setnum=-1;
  int timenow,time_start;
  int next_spark=10000;
  
  double pressure=0.;
  double voltage_amp=0.;
  double voltage_drift=6000.;
  double xx, yy, diff, E1, E2, E3, phi;
  double range_ccd=-1.;
  double Etrack=-1.;
  double Etrig=-1.;
  double Emesh=-1.;
  double TrackX=-10000.;
  double TrackY=-10000.;
  double TrackXStart=-10000.;
  double TrackYStart=-10000.;
  double TrackXEnd=-10000.;
  double TrackYEnd=-10000.;
  double Trackskewness=-1.;
  double Trackmaxpixel=-1.;
  double bestDiff=-1.;
  double phi=-10.;
  double rr=-1.;
  double anodeRMS=0.;
  double meshRMS=0.;
  double cluster_mean=0.;
  double cluster_rms=0.;
  int exposure=0;
  int expose=0;
  double Trackrms=0.;
  double Trackwidth=0.;
  double mesh_peak=0.;
  double mesh_start=0.;	
  double anode_start=0.;
  double mesh_base=0.;
  double anode_base=0.; 
  double mesh_max;
  double anode_max;
  double veto_peak=0.;
  double mesh_width=0.;
  double anode_R0=0.;
  double mesh_R0=0.;
  double mesh_R10=0.;
  double mesh_R25=0.;
  double mesh_R50=0.;
  double mesh_R75=0.;
  double mesh_R90=0.;
  double mesh_F0=0.;
  double mesh_F10=0.;
  double mesh_F25=0.;
  double mesh_F50=0.;
  double mesh_F75=0.;
  double mesh_F90=0.;
  double mesh_peaktime=0.;
  double triggertimestamp[maxentries];
  int triggerindex;
  int badrun; 
  int badrunflag;
  int totaltrack=0;
  int totaltrig=0;
  double totalmesh_allwf=0.;
  double totalanode_allwf=0.;
  
long int orig_filesize=-1;
long int new_filesize=0;
long int orig_filesize2=-1;
long int new_filesize2=0;

      string origfile;
      string skimfile;

      string outfile1;
      std::stringstream out1;
      out1.str("");
      if (firstrun<10000){ outfile1+="0";}
      if (firstrun<1000){ outfile1+="0"; }
      if (firstrun<100){ outfile1+="0";}
      if (firstrun<10){ outfile1+="0"; }
      out1 << outfile1 << firstrun ;
  
      string outfile2;
      std::stringstream out2;
      out2.str("");
      if (lastrun<10000){ outfile2+="0";}
      if (lastrun<1000){ outfile2+="0"; }
      if (lastrun<100){ outfile2+="0";}
      if (lastrun<10){ outfile2+="0"; }
      out2 << outfile2 << lastrun ;
      
      string out1filename=out1.str();
      string out2filename=out2.str();
  
  TFile *histfile=new TFile(Form("outtree_%s_%s.root",out1filename.c_str(),out2filename.c_str()), "RECREATE");
  tree = new TTree("dctpc_eventinfo", "Event info");
  tree->Branch("RunNum", &runnum, "runnum/I");
  tree->Branch("SetNum", &setnum, "setnum/I");
  tree->Branch("SequenceNum", &seqnum, "seqnum/I");
  tree->Branch("ExposureInRun_sec", &expose, "expose/I");
  tree->Branch("EventNum", &evnum, "evnum/I");
  tree->Branch("Image_mean_ccdadu", &image_mean, "image_mean/D");
  tree->Branch("Image_rms_ccdadu", &image_rms, "image_rms/D");
  tree->Branch("Edge", &edge, "edge/I");
  tree->Branch("BurnIn", &burnin, "burnin/I");
  tree->Branch("Pixels_killed", &pixels_killed, "pixels_killed/I");
  tree->Branch("LastSpark", &last_spark, "last_spark/I");
  tree->Branch("NextSpark", &next_spark, "next_spark/I");
  tree->Branch("Ntrack", &ntrack, "ntrack/I");
  tree->Branch("Ntrig", &ntrig, "ntrig/I");
  tree->Branch("Etrack_kev", &Etrack, "Etrack/D");
  tree->Branch("Etrig_kev", &Etrig, "Etrig/D");
  tree->Branch("Emesh_kev", &Emesh, "Emesh/D"); 
  tree->Branch("Track_mean_ccdadu", &cluster_mean, "cluster_mean/D");
  tree->Branch("Track_rms_ccdadu", &cluster_rms, "cluster_rms/D"); 
  tree->Branch("Track_x_pix", &TrackX, "TrackX/D"); 
  tree->Branch("Track_y_pix", &TrackY, "TrackY/D");
  tree->Branch("Track_x_start_pix", &TrackXStart, "TrackXStart/D"); 
  tree->Branch("Track_y_start_pix", &TrackYStart, "TrackYStart/D");
  tree->Branch("Track_x_end_pix", &TrackXEnd, "TrackXEnd/D"); 
  tree->Branch("Track_y_end_pix", &TrackYEnd, "TrackYEnd/D");
  tree->Branch("Track_range_pix", &range_ccd, "range_ccd/D");
  tree->Branch("Track_fitwidth_pix", &Trackrms, "Trackrms/D");
  tree->Branch("Track_width_pix", &Trackwidth, "Trackwidth/D");
  tree->Branch("Track_maxpixel_ccdadu", &Trackmaxpixel, "Trackmaxpixel/D");
  tree->Branch("Track_neighbors", &neighbors, "neighbors/I");
  tree->Branch("Track_pixels", &Tracknpixel, "Tracknpixel/I");
  tree->Branch("Track_phi_deg", &phi, "phi/D");
  tree->Branch("Track_skewness", &Trackskewness, "Trackmskewness/D");
  tree->Branch("Anode_rms_v", &anodeRMS, "anodeRMS/D");
  tree->Branch("Mesh_rms_v", &meshRMS, "meshRMS/D");
  tree->Branch("Mesh_peak_v", &mesh_peak, "mesh_peak/D");
  tree->Branch("Mesh_base_v", &mesh_base, "mesh_base/D");
  tree->Branch("Anode_base_v", &anode_base, "anode_base/D");
  tree->Branch("Mesh_max_v", &mesh_max, "mesh_max/D");
  tree->Branch("Anode_max_v", &anode_max, "anode_max/D");
  tree->Branch("Veto_peak_v", &veto_peak, "veto_peak/D");
  tree->Branch("Mesh_starttime_samp", &mesh_start, "mesh_start/D");
  tree->Branch("Anode_starttime_samp", &anode_start, "anode_start/D");
  tree->Branch("Mesh_peaktime_samp", &mesh_peaktime, "mesh_peaktime/D");
  tree->Branch("Mesh_totaltime_samp", &mesh_width, "mesh_width/D");
  tree->Branch("Anode_R0time_samp", &anode_R0, "anode_R0/D");
  tree->Branch("Mesh_R0time_samp", &mesh_R0, "mesh_R0/D");
  tree->Branch("Mesh_R10time_samp", &mesh_R10, "mesh_R10/D");
  tree->Branch("Mesh_R25time_samp", &mesh_R25, "mesh_R25/D");
  tree->Branch("Mesh_R50time_samp", &mesh_R50, "mesh_R50/D");
  tree->Branch("Mesh_R75time_samp", &mesh_R75, "mesh_R75/D");
  tree->Branch("Mesh_R90time_samp", &mesh_R90, "mesh_R90/D");
  tree->Branch("Mesh_F0time_samp", &mesh_F0, "mesh_F0/D");
  tree->Branch("Mesh_F10time_samp", &mesh_F10, "mesh_F10/D");
  tree->Branch("Mesh_F25time_samp", &mesh_F25, "mesh_F25/D");
  tree->Branch("Mesh_F50time_samp", &mesh_F50, "mesh_F50/D");
  tree->Branch("Mesh_F75time_samp", &mesh_F75, "mesh_F75/D");
  tree->Branch("Mesh_F90time_samp", &mesh_F90, "mesh_F90/D");  
  tree->Branch("Timenow_sec",&timenow, "timenow/I");
  tree->Branch("Triggerindex",&triggerindex, "triggerindex/I");
  tree->Branch("Triggertimestamp_samp",&triggertimestamp, "triggertimestamp[ntrig]/D");
  tree->Branch("Mesh_total_allwf_kev", &totalmesh_allwf, "totalmesh_allwf/D");
  tree->Branch("Anode_total_allwf_kev", &totalanode_allwf, "totalanode_allwf/D");
  
  tree2 = new TTree("dctpc_runinfo", "Run info");
  tree2->Branch("RunNum", &runnum, "runnum2/I");
  tree2->Branch("SetNum", &setnum, "setnum/I");
  tree2->Branch("SequenceNum", &seqnum, "seqnum/I");
  tree2->Branch("Exposure_sec", &exposure, "exposure/I");
  tree2->Branch("Totaltracks", &totaltrack, "totaltrack/I");
  tree2->Branch("Totaltrigs", &totaltrig, "totaltrig/I");
  tree2->Branch("Time_startofrun_sec", &time_start, "time_start/I");
  tree2->Branch("Pressure_torr", &pressure, "pressure/D");
  tree2->Branch("Voltage_amp_volts", &voltage_amp, "voltage_amp/D");
  tree2->Branch("Voltage_drift_volts", &voltage_drift, "voltage_drift/D");
//start run loop

for (int x = firstrun; x <= lastrun; x++)
{


badrunflag=0;
totaltrack=0;
totaltrig=0;
next_spark=10000;
string line;


      runnum=x;
      
      voltage_drift=6000.;
           
      if(runnum>=889&&runnum<=891)
      {
      seqnum=0;
      lightCalib = .48 * 0.7663;
      anodeCalib = 23.2 * 0.771;
      meshCalib = 37.8 * 0.769;
      }
      
      if(runnum>=893&&runnum<=896)
      {
      seqnum=1;
      lightCalib = .48 * 0.89;
      anodeCalib = 23.2 * 0.8861;
      meshCalib = 37.8 * 0.8853;
      }
      
      if(runnum>=897&&runnum<=904)
      {
      seqnum=2;
      lightCalib = .48 * 0.8887;
      anodeCalib = 23.2 * 0.8849;
      meshCalib = 37.8 * 0.881;
      }
      
      if(runnum>=910&&runnum<=917)
      {
      seqnum=3;
      lightCalib = .48 * 0.8644;
      anodeCalib = 23.2 * 0.857;
      meshCalib = 37.8 * 0.856;
      }
      
      if(runnum>=919&&runnum<=925)
      {
      seqnum=4;
      lightCalib = .48 * 0.7078;
      anodeCalib = 23.2 * 0.715;
      meshCalib = 37.8 * 0.7134;
      }
      
      if(runnum>=926&&runnum<=938)
      {
      seqnum=5;
      lightCalib = .48 * 0.968;
      anodeCalib = 23.2 * 0.8401;
      meshCalib = 37.8 * 0.8392;
      }
      
      if(runnum>=939&&runnum<=954)
      {
      seqnum=6;   
      lightCalib = .48 * 0.9719;
      anodeCalib = 23.2 * 0.8291;
      meshCalib = 37.8 * 0.8284;
      }
      
      if(runnum>=955&&runnum<=1645)
      seqnum=7;
      
      if(runnum>=1646&&runnum<=2205)
      seqnum=8;
      
      if(runnum>=2206&&runnum<=2648)
      seqnum=9; 
      
      if(runnum>=2650&&runnum<=3868)
      seqnum=10; 
        
      if(runnum>=3876&&runnum<=5789)
      seqnum=11; 
      
      if(runnum>=5792&&runnum<=7520)
      seqnum=12;
      
      if(runnum>=7530&&runnum<=9143)
      seqnum=13;

      if(runnum>=9147&&runnum<=12833)
      seqnum=14;
      
      if(runnum>=12837&&runnum<=13311)
      seqnum=15;
      
      if(runnum>=13315&&runnum<=15161)
      seqnum=16;
      
      if(runnum>=15162&&runnum<=16073)
      seqnum=17;

      if(runnum>=16074&&runnum<=16175)
      seqnum=18;

      if(runnum>=16150&&runnum<=17275)
      seqnum=19;	
      
      if(runnum>=17276&&runnum<=17334)
      seqnum=20;
      
      if(runnum>=17336&&runnum<=17349)
      seqnum=21;
      
      if(runnum>=17351&&runnum<=17366)
      seqnum=22;
      
      if(runnum>=17369&&runnum<=17370)
      seqnum=23;
              
      if(runnum>=889&&runnum<=954)
      setnum=0;
      
      if(runnum>=955&&runnum<=3868)
      setnum=1;
      
      if(runnum>=3876&&runnum<=5789)
      setnum=2;

      if(runnum>=5792&&runnum<=17334)
      {
      setnum=3;
      voltage_drift=7500.;
      }
      
      if(runnum>=5792&&runnum<=17334)
      {
      setnum=3;
      voltage_drift=7500.;
      }
      
      if(runnum>=17336&&runnum<=17366)
      {
      setnum=4;
      voltage_drift=6200.;
      }
      
      if(runnum>=17369&&runnum<=17370)
      {
      setnum=5;
      voltage_drift=4480.;
      }
      
      
      if(seqnum!=seqnum2)
      seqcounter=0;
      
      seqnum2=seqnum;
    
      if(BATCH==0)
      {
      origfile = "/net/nudsk0001/d00/scratch/dctpc_tmp/bigdctpc_data/BigDCTPC_run_";
      skimfile = "/net/nudsk0001/d00/scratch/dctpc_tmp/bigdctpc_skim/BigDCTPC_run_";
      }
      else
      {
      origfile = "./BigDCTPC_run_";
      skimfile = "./BigDCTPC_run_";   
      }
//       origfile = "/mnt/hadoop/mitgroups/dchooz/dctpc_tmp/bigdctpc_data/BigDCTPC_run_";
//       skimfile = "/mnt/hadoop/mitgroups/dchooz/dctpc_tmp/bigdctpc_skim/BigDCTPC_run_";

//uncomment all this for batch running:

      
      string skimend = "skim.root";
      string origend = ".root";
      string origfilename;
      string skimfilename;
      sstm.str("");
      sstmxxx.str("");
      string xxx;
      if (x<10000){ origfile+="0"; skimfile+="0"; xxx+="0";}
      if (x<1000){ origfile+="0"; skimfile+="0"; xxx+="0";}
      if (x<100){ origfile+="0"; skimfile+="0"; xxx+="0";}
      if (x<10){ origfile+="0"; skimfile+="0"; xxx+="0";}
      sstm << origfile << x << origend;
      sstmxxx << xxx << x;
      origfilename = sstm.str();
      sstm.str("");
      sstm << skimfile << x << skimend;
      skimfilename = sstm.str();
      cout << origfilename << endl;
      ifstream ifile(origfilename.c_str());
      ifstream ifile2(skimfilename.c_str());
      if(!ifile)
	continue;
      if(!ifile2)
	continue;

if(BATCH==1)
{
   stringstream t;
   t<<gSystem->GetFromPipe(Form("du -sb /mnt/hadoop/mitgroups/dchooz/dctpc_tmp/bigdctpc_skim/%s |awk '{print $1}'",skimfilename.c_str()));
   t >> orig_filesize;
   
   stringstream t;
   t<<gSystem->GetFromPipe(Form("du -sb %s |awk '{print $1}'",skimfilename.c_str()));
   t >> new_filesize;

   stringstream t;
   t<<gSystem->GetFromPipe(Form("du -sb /mnt/hadoop/mitgroups/dchooz/dctpc_tmp/bigdctpc_data/%s |awk '{print $1}'",origfilename.c_str()));
   t >> orig_filesize2;
   
   stringstream t;
   t<<gSystem->GetFromPipe(Form("du -sb %s |awk '{print $1}'",origfilename.c_str()));
   t >> new_filesize2;

if(orig_filesize!=new_filesize)
continue;

if(orig_filesize2!=new_filesize2)
continue;

}


      DmtpcSkimDataset d;
      try
      {
      d.openRootFile(skimfilename.c_str());     
      d.loadDmtpcEvent(true,origfilename.c_str());
      }
      catch(const std::exception& e)
      {
	  continue;	
      }
      DmtpcSkimDataset d2;
      try
      {
      d2.openRootFile(skimfilename.c_str());     
      d2.loadDmtpcEvent(true,origfilename.c_str());
      }
      catch(const std::exception& e)
      {
	  continue;	
      }
      
      
      Long_t nEvents=d.tree()->GetEntriesFast();
	  runnum2=x; 
	  exposure=0;	
	  expose=0;
	  lastSpark=-1;
	  
std::string s = sstmxxx.str();

stringstream ff;
ff<<gSystem->GetFromPipe(Form("grep run_%s /net/hisrv0001/home/spitzj/runlog|awk '{print $46}'",s.c_str()));
ff >> pressure;

stringstream fff;
fff<<gSystem->GetFromPipe(Form("grep run_%s /net/hisrv0001/home/spitzj/runlog|awk '{print $30}'",s.c_str()));
fff >> voltage_amp;

voltage_amp*=1000.;
// cout<<pressure<<" "<<voltage_drift<<" "<<voltage_amp<<endl;

seqcounter++;

std::vector<int> sparkvector;
for(int i=0; i<nEvents; i++){ 

DmtpcSkimEvent* ev2=d2.event(); //creating an event object		
d2.getEvent(i);

if(ev2->spark(0)){sparkvector.push_back(ev2->eventNumber());lastSpark = ev2->eventNumber();continue;} 
	
ntrack=ev2->ntracks(0);
for(int k=0;k<ev2->ntracks(0);k++)
{	
	  if (ev2->maxpixel(0,k)>1000){
	  sparkvector.push_back(ev2->eventNumber());
	  lastSpark = ev2->eventNumber();
	  continue;}
}

if(i-lastSpark>=8)
expose++;

}

lastSpark = -1;

//start event loop 
for(int i=0; i<nEvents; i++){    

if(i%100==0)
cout<<"Event: "<<i<<" / "<<nEvents<<endl;
    
evnum=i;	
DmtpcSkimEvent* ev=d.event(); //creating an event object		
d.getEvent(i);

if(i==0)
time_start=ev->timenow(0);

	if(ev->spark(0)){lastSpark = ev->eventNumber(); continue;} 
	
	ntrack=ev->ntracks(0);
	for(int k=0;k<ev->ntracks(0);k++)
	  {	
	  if (ev->maxpixel(0,k)>1000){lastSpark = ev->eventNumber();continue;}//maxpixel has to be less than 800ADU. also, the event might have been a spark!
	  }
	if(evnum-lastSpark<8){continue;} // make sure that at least 7 events have passed after a spark

	for(int a=0;a<sparkvector.size();a++)
	{
	if(i<sparkvector[a])
	{
	next_spark=sparkvector[a]-evnum;
	break;
	}
	next_spark=10000;
	}
	

    exposure++;//increase the integrated exposure as long as the event is not a spark or close to a spark in time

	//if(ev->ntracks(0)==0){continue;}		

	Etrack=-1.;
	Etrig=-1.;
	Emesh=-1.;
	passTrack=0;
	passTrig=0;
	passAll=0;
	timenow = ev->timenow(0);
	bestDiff=1e9;
	Etrack = -1.;
	phi = -1.;
	range_ccd=-1.;
	TrackX = -1.;
	TrackY = -1.;
	Trackskewness=-1.;
	edge=-1;
	burnin=-1;
	cluster_mean=-1.;
	cluster_rms=-1.;
	neighbors=-1;
	Trackmaxpixel=-1.;
	Tracknpixel=-1;
	Trackrms=-1.;
	Trackwidth=-1.;
	TrackXStart = -1.;
	TrackYStart = -1.;
	TrackXEnd = -1.;
	TrackYEnd = -1.;
	


image_mean=ev->image_mean(0);
image_rms=ev->image_rms(0);
last_spark=evnum-lastSpark;
//cout<<image_rms<<endl;
pixels_killed=ev->pixels_killed(0);

	diff=1e9;	
	
	if(d.orig_event()->scopeDataInfo(0)==NULL){continue;}//no waveforms!!

    TObjArray* arr = ev->waveform_vectors();
    CspWfVector* anode = (CspWfVector*) arr->At(0);
	FastWfVector* mesh = (FastWfVector*) arr->At(1);
	CspWfVector* veto = (CspWfVector*) arr->At(2); 

totalmesh_allwf=0.;
totalanode_allwf=0.;

totaltrig+=mesh->size();
totaltrack+=ev->ntracks(0);

	    //loop over triggers
	    ntrig=mesh->size();
	for (int nt = 0; nt < mesh->size(); nt++)
	{	
	ScopeWaveformData *hwf=d.orig_event()->rawScopeData(nt);	
	triggertimestamp[nt]=hwf->getTimeStamp();

	totalmesh_allwf+=mesh->at(nt,0).getIntegral()*meshCalib;
	totalanode_allwf+=(anode->at(nt,0).getPeak()*1000.)*anodeCalib;
	
	//loop over tracks in each event
	  for(int k=0;k<ev->ntracks(0);k++)
	  {	 
 
	    if (ev->E(0,k)<1){continue;} //Cut if E is below 1 (measured in ADU)
	    if (ev->range(0,k)<=0){continue;} //Cut if it has a zero range
	    if (ev->maxpixel(0,k)/ev->E(0,k)>0.25){continue;} //To eliminate noise artifacts the max pixel has to be less than 25% of the total signal      
           
	    passTrig=0;


	    passTrig++;//increment number of tracks that pass the trigger cuts
	    E1 = ev->E(0,k)*lightCalib;
	    E2 = (anode->at(nt,0).getPeak()*1000.)*anodeCalib;
	    diff=TMath::Abs( (E1 - E2)/(E1 + E2) );
	    
	    
	    //cout<<ev->minorAxis(0,k)<<endl;
	    
	    	if (fabs(diff)<fabs(bestDiff)) 
	    	{	
			Etrack = E1;
			phi = ev->phi(0,k);
			phi = atan2(sin(phi),cos(phi)) * 180./ 3.1416;   
			range_ccd=ev->range(0,k);	         	      	    
	    	TrackX = ev->x(0,k)-512;
	    	TrackY = ev->y(0,k)-512; 
        	Trackskewness=ev->skewness(0,k);
        	edge=ev->edge(0,k);
        	burnin=ev->nburnin(0,k);
        	cluster_mean=ev->cluster_mean(0,k);
        	cluster_rms=ev->cluster_rms(0,k);
        	neighbors=ev->neighbors(0,k);
        	Trackmaxpixel=ev->maxpixel(0,k);
        	Tracknpixel=ev->npixel(0,k);
        	Trackrms=sqrt(ev->transverse_moment(0,2,k)); 
        	Trackwidth=4*ev->npixel(0,k)/ev->range(0,k);
        	//cout<<ev->transverse_moment(0,1,k)<<" "<<ev->transverse_moment(0,2,k)<<endl; 
        	 
        	 
        	TrackXStart = (double)ev->xbegin(0,k)-512;
        	TrackYStart = (double)ev->ybegin(0,k)-512;
        	TrackXEnd = (double)ev->xend(0,k)-512;
        	TrackYEnd = (double)ev->yend(0,k)-512;
	    	
			Etrig = E2;			
			mesh_peak=mesh->at(nt,0).getPeak();
			veto_peak=veto->at(nt,0).getPeak();
			anode_R0=anode->at(nt,0).getRise0();
			mesh_R0=mesh->at(nt,0).getRise0();
			mesh_R10=mesh->at(nt,0).getRise10();
			mesh_R25=mesh->at(nt,0).getRise25();
			mesh_R50=mesh->at(nt,0).getRise50();
			mesh_R75=mesh->at(nt,0).getRise75();
			mesh_R90=mesh->at(nt,0).getRise90();
			mesh_F0=mesh->at(nt,0).getFall0();
			mesh_F10=mesh->at(nt,0).getFall10();
			mesh_F25=mesh->at(nt,0).getFall25();
			mesh_F50=mesh->at(nt,0).getFall50();
			mesh_F75=mesh->at(nt,0).getFall75();
			mesh_F90=mesh->at(nt,0).getFall90();
			mesh_width=mesh->at(nt,0).getRise0()+mesh->at(nt,0).getFall0();
			mesh_peaktime=mesh->at(nt,0).getSlowPeakTime();
			Emesh=mesh->at(nt,0).getIntegral()*meshCalib;
			meshRMS=mesh->at(nt).getRMS();
	        anodeRMS=anode->at(nt).getRMS();
	        mesh_start=mesh->at(nt,0).getStartTime();	
	        anode_start=anode->at(nt,0).getStartTime();	
	        mesh_base=mesh->at(nt).getBase();
	        anode_base=anode->at(nt).getBase();
	        mesh_max=mesh->at(nt).getWfMax();
	        anode_max=anode->at(nt).getWfMax();
	        triggerindex=nt;
	        bestDiff = diff;	        
	    	}
	    		    	
	    } // end track loop 
	    
	   if(ev->ntracks(0)==0) 
	    {
	    E1 = mesh->at(nt,0).getIntegral()*meshCalib;
	    E2 = (anode->at(nt,0).getPeak()*1000.)*anodeCalib;
	    diff=TMath::Abs( (E1 - E2)/(E1 + E2) );
	    
	    	if (fabs(diff)<fabs(bestDiff)) 
	    	{	
	    	
	    	Etrack = -1.;
			phi = -1.;   
			range_ccd=-1.;	         	      	    
	    	TrackX = -1.;
	    	TrackY = -1.; 
        	Trackskewness=-1.;
        	edge=-1;
        	burnin=-1;
        	cluster_mean=-1.;
        	cluster_rms=-1.;
        	neighbors=-1;
        	Trackmaxpixel=-1.;
        	Tracknpixel=-1;
        	Trackrms=-1.;  
        	TrackXStart = -1.;
        	TrackYStart = -1.;
        	TrackXEnd = -1.;
        	TrackYEnd = -1.;

			Etrig = E2;			
			mesh_peak=mesh->at(nt,0).getPeak();
			veto_peak=veto->at(nt,0).getPeak();
			anode_R0=anode->at(nt,0).getRise0();
			mesh_R0=mesh->at(nt,0).getRise0();
			mesh_R10=mesh->at(nt,0).getRise10();
			mesh_R25=mesh->at(nt,0).getRise25();
			mesh_R50=mesh->at(nt,0).getRise50();
			mesh_R75=mesh->at(nt,0).getRise75();
			mesh_R90=mesh->at(nt,0).getRise90();
			mesh_F0=mesh->at(nt,0).getFall0();
			mesh_F10=mesh->at(nt,0).getFall10();
			mesh_F25=mesh->at(nt,0).getFall25();
			mesh_F50=mesh->at(nt,0).getFall50();
			mesh_F75=mesh->at(nt,0).getFall75();
			mesh_F90=mesh->at(nt,0).getFall90();
			mesh_width=mesh->at(nt,0).getRise0()+mesh->at(nt,0).getFall0();
			mesh_peaktime=mesh->at(nt,0).getSlowPeakTime();
			Emesh=mesh->at(nt,0).getIntegral()*meshCalib;
			meshRMS=mesh->at(nt).getRMS();
	        anodeRMS=anode->at(nt).getRMS();
	        mesh_start=mesh->at(nt,0).getStartTime();	
	        anode_start=anode->at(nt,0).getStartTime();
	        mesh_base=mesh->at(nt).getBase();
	        anode_base=anode->at(nt).getBase();
	        mesh_max=mesh->at(nt).getWfMax();
	        anode_max=anode->at(nt).getWfMax();
	        triggerindex=nt;	
	        bestDiff = diff;		
	    	} 
	    
	    }
    
	    ntotalTrig+=passTrig;
	    
	  }//end trigger loop

	ntotalTrack+=passTrack;
	
	//if (passTrack!=1){continue;} // events are unlikely to have more than 1 track
// 	if (passTrig==0){continue;} 

	passAll=1;
		//cout<<Etrack<<" "<<Etrig<<" "<<Emesh<<endl;
	tree->Fill();	
	
}//end event loop

tree2->Fill();
cout <<"Total seconds of exposure: "<<exposure<<" "<<expose<<endl;
}//end file loop
Exemple #3
0
void check() {
    /*
     TString   name = "../filelistMWGfvtx.dat";
     TString   namec = "../filelistMWGfvtxcalib.dat";
     TString   name1 = "../filelistMWGfvtx1.dat";
     TString   name2 = "../filelistMWGfvtx2.dat";
     TString   name1c = "../filelistMWGfvtx1calib.dat";
     TString   name2c = "../filelistMWGfvtx2calib.dat";

    */
    TString   name = "../filelistMWGmb.dat";
    TString   namec = "../filelistMWGmbcalib.dat";
    TString   name1 = "../filelistMWGmb1.dat";
    TString   name2 = "../filelistMWGmb2.dat";
    TString   name1c = "../filelistMWGmb1calib.dat";
    TString   name2c = "../filelistMWGmb2calib.dat";

    //  ofstream fout("checkfvtx.out");
    //ofstream fout("checkfvtx1.out");
    ofstream fout("checkmb.out");
    // for(int i=0;i<1376;i++){
    float bbcv;
    float bbcvc;
    float bbcv1;
    float bbcv1c;
    float bbcv2;
    int nfvtxtrack1;
    int nfvtxtrack1c;
    int nfvtxtrack2;
    int nfvtxtrack2c;
    for(int i=0; i<754; i++) {
        if(i!=693 && i!=44)continue;
        //    for(int i=256;i<258;i++){
        //  if(i!=170 && i!=171 && i!=174 && i!=178 && i!=257 && i!=300 && i!=460 && i!=491 && i!=535 && i!=621)continue;
        //    if(i!=43)continue;
        TString ifile(readline(Form("%s",name.Data()),i));
        TString ifilec(readline(Form("%s",namec.Data()),i));
        TString ifile1(readline(Form("%s",name1.Data()),i));
        TString ifile2(readline(Form("%s",name2.Data()),i));
        TString ifile1c(readline(Form("%s",name1c.Data()),i));
        TString ifile2c(readline(Form("%s",name2c.Data()),i));
        TFile *f = TFile::Open(ifile);
        TFile *fc = TFile::Open(ifilec);
        TFile *f1 = TFile::Open(ifile1);
        TFile *f2 = TFile::Open(ifile2);
        TFile *f1c = TFile::Open(ifile1c);
        TFile *f2c = TFile::Open(ifile2c);
        TTree *t = (TTree*)f->Get("tree");
        TTree *tc = (TTree*)fc->Get("tree");
        TTree *t1 = (TTree*)f1->Get("tree");
        TTree *t2 = (TTree*)f2->Get("tree");
        TTree *t1c = (TTree*)f1c->Get("tree");
        TTree *t2c = (TTree*)f2c->Get("tree");
        t->SetBranchAddress("bbcv",&bbcv);
        tc->SetBranchAddress("bbcv",&bbcvc);
        t1->SetBranchAddress("bbcv",&bbcv1);
        t1c->SetBranchAddress("bbcv",&bbcv1c);
        t2->SetBranchAddress("bbcv",&bbcv2);
        t1->SetBranchAddress("nfvtxtrack",&nfvtxtrack1);
        t1c->SetBranchAddress("nfvtxtrack",&nfvtxtrack1c);
        t2->SetBranchAddress("nfvtxtrack",&nfvtxtrack2);
        t2c->SetBranchAddress("nfvtxtrack",&nfvtxtrack2c);
        cout<<t->GetEntries()<<"\t"<<tc->GetEntries()<<"\t"<<t1->GetEntries()<<"\t"<<t1c->GetEntries()<<"\t"<<t2->GetEntries()<<"\t"<<t2c->GetEntries()<<"\t";
        fout<<t->GetEntries()<<"\t"<<tc->GetEntries()<<"\t"<<t1->GetEntries()<<"\t"<<t1c->GetEntries()<<"\t"<<t2->GetEntries()<<"\t"<<t2c->GetEntries()<<"\t";
        // cout<<ifile<<"\t";//<<t2->GetEntries();
        t->GetEntry(t->GetEntries()-100);
        tc->GetEntry(tc->GetEntries()-100);
        t1->GetEntry(t1->GetEntries()-100);
        t1c->GetEntry(t1c->GetEntries()-100);
        t2->GetEntry(t1->GetEntries()-100);
        t2c->GetEntry(t1c->GetEntries()-100);
//            t->GetEntry(0);
//            t1->GetEntry(0);
        //          cout<<bbcv<<"\t"<<bbcvc<<"\t"<<bbcv1<<"\t"<<bbcv1c<<"\t"<<bbcv2<<endl;
        //          cout<<nfvtxtrack1<<"\t"<<nfvtxtrack1c<<"\t"<<nfvtxtrack2<<"\t"<<nfvtxtrack2c<<endl;
//           fout<<t->GetEntries()<<"\t"<<tc->GetEntries()<<"\t"<<t1->GetEntries()<<"\t"<<t1c->GetEntries()<<"\t"<<t2->GetEntries()<<"\t"<<t2c->GetEntries();
        if(tc->GetEntries()!=t2c->GetEntries() || nfvtxtrack1c != nfvtxtrack2c)
            //  if(tc->GetEntries()!=t1c->GetEntries() || bbcvc!=bbcv1c)
        {
            cout<<"BAD";
            fout<<"BAD";
        }
        if(tc->GetEntries()!=0)
            if(1.0*t->GetEntries() / tc->GetEntries()>1.01)
            {
                cout<<"Number BAD!";
                fout<<"Number BAD!";
            }
        if(t1c->GetEntries()!=0)
            if(1.0*t1->GetEntries() / t1c->GetEntries()>1.01)
            {
                cout<<"Number1 BAD!";
                fout<<"Number1 BAD!";
            }
        if(t2c->GetEntries()!=0)
            if(1.0*t2->GetEntries() / t2c->GetEntries()>1.01)
            {
                cout<<"Number2 BAD!";
                fout<<"Number2 BAD!";
            }
//            if(bbcv!=bbcv1) cout<<"BAD!";
        cout<<endl;
        fout<<endl;
        f->Close();
        fc->Close();
        f1->Close();
        f1c->Close();
        f2->Close();
        f2c->Close();
    }
}
Exemple #4
0
void CCDimage14(int firstrun, int lastrun)
{
  gStyle->SetPalette(1,0); 
  gSystem->Load("libMaxCam");
  gSystem->Load("libWaveformTools.so");

  std::stringstream sstm;

  TH2F * sum = 0; 
  TH2I * count = 0;
  TH2F * p=0;
         sum = new TH2F("alpha_sum","alpha_sum",256,0,1024,256,0,1024); 
        count = new TH2I("alpha_count","alpha_count",256,0,1024,256,0,1024);
  const int c = 0;
 
  gROOT->cd(); 

  int runnum;
  int setnum;
  
    if		(firstrun>=889 && lastrun<=954)		{setnum=0;}
    else if	(firstrun>=955 && lastrun<=3868)	{setnum=1;}
    else if	(firstrun>=3876 && lastrun<=5789)	{setnum=2;}
	else if	(firstrun>=5792)					{setnum=3;}
	else
	{
	gApplication->Terminate();
	exit;}
  
  
for (int x = firstrun; x <= lastrun; x++){
	runnum=x;
	
       string origfile = "/net/nudsk0001/d00/scratch/dctpc_tmp/bigdctpc_data/BigDCTPC_run_";
       string skimfile = "/net/nudsk0001/d00/scratch/dctpc_tmp/bigdctpc_skim/BigDCTPC_run_";  
      
//            string origfile = "/net/hisrv0001/home/spitzj/myOutput_";
//      string skimfile = "/net/hisrv0001/home/spitzj//myOutput_";
      
      string skimend = "skim.root";
      string origend = ".root";
      string origfilename;
      string skimfilename;
      sstm.str("");
      if (x<10000){ origfile+="0"; skimfile+="0"; }
      if (x<1000){ origfile+="0"; skimfile+="0"; }
      if (x<100){ origfile+="0"; skimfile+="0"; }
      if (x<10){ origfile+="0"; skimfile+="0"; }
      sstm << origfile << x << origend;
      origfilename = sstm.str();
      sstm.str("");
      sstm << skimfile << x << skimend;
      skimfilename = sstm.str();
      cout << origfilename << endl;
      ifstream ifile(origfilename.c_str());
      ifstream ifile2(skimfilename.c_str());
      if(!ifile)
	  continue;
      if(!ifile2)
	continue;
  	DmtpcSkimDataset d;
  	d.openRootFile(skimfilename.c_str());    
  	d.loadDmtpcEvent(true,origfilename.c_str());
  	for (int i = 0; i < d.nevents(); i ++){
        if(i%100==0){
			cout<<"Event: "<<i<<endl;
		}

	//cout<<"here"<<endl
    d.getEvent(i);    
    //cout<<"here2"<<endl;
    for (int t =0 ; t < d.event()->ntracks(c); t++)
    {
      if(d.event()->maxpixel(0,t)>150){continue;}
      if(d.event()->spark(0)){continue;} 
      p = (TH2F*)d.event()->cluster(c)->getImage(); 
      vector<int> clust = d.event()->cluster(c)->getCluster(t); 
     
    	for (vector<int>::iterator it = clust.begin(); it!=clust.end(); it++)
		{
	  		sum->SetBinContent(*it, sum->GetArray()[*it] + p->GetArray()[*it]);
	  		count->SetBinContent(*it, count->GetArray()[*it] + 1); 
		}    
    }
  }
 }

  TH2F * normalized = (TH2F*) sum->Clone("normalized"); 
  normalized->SetName("normalized");
  normalized->Divide(count); 
  normalized->SetStats(0);
  normalized->Draw("COLZ");
  c1->Print(Form("CCDimage14_set_%d_runs_%d_%d.pdf",setnum,firstrun,lastrun));

  TFile *f=new TFile(Form("CCDimage14_set_%d_runs_%d_%d.root",setnum,firstrun,lastrun),"RECREATE");
  normalized->Write();
  f->Close();

  gApplication->Terminate();
}
Exemple #5
0
int CmdPull::execute (std::string& output)
{
  context.footnote ("The 'pull' command is deprecated, and will be removed in a subsequent release.");

  std::vector <std::string> words = context.a3.extract_words ();
  std::string file;
  if (words.size ())
    file = words[0];

  Uri uri (file, "pull");
  uri.parse ();

  if (uri._data.length ())
  {
		Directory location (context.config.get ("data.location"));

    if (! uri.append ("{pending,undo,completed}.data"))
      throw format (STRING_CMD_PULL_NOT_DIR, uri._path);

		Transport* transport;
		if ((transport = Transport::getTransport (uri)) != NULL)
		{
			transport->recv (location._data + "/");
			delete transport;
		}
		else
		{
      // Verify that files are not being copied from rc.data.location to the
      // same place.
      if (Directory (uri._path) == Directory (context.config.get ("data.location")))
        throw std::string (STRING_CMD_PULL_SAME);

      // copy files locally

      // remove {pending,undo,completed}.data
      uri._path = uri.parent();

      Path path1 (uri._path + "undo.data");
      Path path2 (uri._path + "pending.data");
      Path path3 (uri._path + "completed.data");

      if (path1.exists() && path2.exists() && path3.exists())
      {
//        if (confirm ("xxxxxxxxxxxxx"))
//        {
          std::ofstream ofile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary);
          std::ifstream ifile1 (path1._data.c_str()                    , std::ios_base::binary);
          ofile1 << ifile1.rdbuf();

          std::ofstream ofile2 ((location._data + "/pending.data").c_str(), std::ios_base::binary);
          std::ifstream ifile2 (path2._data.c_str()                    , std::ios_base::binary);
          ofile2 << ifile2.rdbuf();

          std::ofstream ofile3 ((location._data + "/completed.data").c_str(), std::ios_base::binary);
          std::ifstream ifile3 (path3._data.c_str()                    , std::ios_base::binary);
          ofile3 << ifile3.rdbuf();
//        }
      }
      else
      {
        throw format (STRING_CMD_PULL_MISSING, uri._path);
      }
		}

    output += format (STRING_CMD_PULL_TRANSFERRED, uri.ToString ()) + "\n";
  }
  else
    throw std::string (STRING_CMD_PULL_NO_URI);

  return 0;
}
Exemple #6
0
int main(int argc, char* argv[])
{
	string cfgfile;
	char* file1;
	char* file2;
	char* resultfile;

	//check inputs
    if (argc < 4) { 
        cout << "VIDEO ALIGNMENT\n"; 
        cout << "--------------------------------------------------\n"; 
        cout << "Syntax: align <video1> <video2> <result> [config]\n"; 
        cout << "\n"; 
        cout << "Example 1: align.exe video1.avi video2.avi result.txt\n"; 
        cout << "\n"; 
        cout << "Example 2: align.exe video1.avi video2.avi result.txt myconfig.ini\n"; 
        cout << "\n";         
		cout << "--------------------------------------------------\n"; 
        cout << "TCL Research America\n"; 
        cout << "Armin Kappeler\n"; 
        cout << "08//29//2013\n"; 
        cin.get();
        exit(0);
    } else { // if we got enough parameters...
		file1 = argv[1];
		file2 = argv[2];
		resultfile = argv[3];

		if (argc >=5) {
			cfgfile = argv[4];
		}else {
			cfgfile = "config.ini";
		}

		ofstream ofile(resultfile);
		if (!ofile) {
			cout << "Invalid input argument 3: invalid output filename\n";
			exit(0);
		}
		ofile.close();		
		ifstream ifile1(file1);
		if (!ifile1) {
			cout << "Invalid input argument 1: First video doesn't exist\n";
			exit(0);
		}
		ifile1.close();
		ifstream ifile2(file2);
		if (!ifile2) {
			cout << "Invalid input argument 2: Second video doesn't exist\n";
			exit(0);
		}
		ifile2.close();
		ifstream ifile3(cfgfile);
		if (!ifile3) {
			cout << "No configuration file found (Default filename: \"config.ini\")\n";
			exit(0);
		}
		ifile3.close();
	}
	//load configuration
	cout << "READ CONFIGURATION FILE\n";
	ConfigFile cfg(cfgfile);
	SequentialAlignment sa;
	loadConfiguration(cfg,sa);

	//call Video Alignment
	cout << "VIDEO SEQUENCE ALIGNMENT\n";
	sa.alignVideos(file1, file2, resultfile);

	return 0;
}