示例#1
0
void sillyMacro(){

  char headerName[1000];
  char gpsName[1000];
  char corName[1000];

  RawAnitaHeader *header =0;
  Adu5Pat *pat =0;
  Adu5Pat *pat2 =0;
  CorrelationSummaryAnita3 *cor=0;

  TChain *gpsChain = new TChain("adu5PatTree");
  TChain *gpsChain2 = new TChain("adu5PatTree");
  TChain *headChain = new TChain("headTree");
  TChain *corChain = new TChain("corTree");

  for (unsigned int run=331;run<355;++run){
    sprintf(headerName,"/unix/anita3/flight1415/root/run%d/timedHeadFile%d.root",run,run);
    sprintf(gpsName,"/unix/anita3/flight1415/root/run%d/gpsEvent%d.root",run,run);
    sprintf(corName, "/unix/anita3/linda/corTrees/corRun_NEW11_HPOL_%d.root", run);
    headChain->Add(headerName);
    gpsChain->Add(gpsName);
    gpsChain2->Add(gpsName);
    corChain->Add(corName);
  }
  headChain->SetBranchAddress("header",&header);
  gpsChain->SetBranchAddress("pat",&pat);
  gpsChain2->SetBranchAddress("pat",&pat2);
  corChain->SetBranchAddress("cor",&cor);

  UInt_t gps_eventNumber;
  gpsChain->SetBranchAddress("eventNumber", &gps_eventNumber);
  UInt_t gps2_eventNumber;
  gpsChain2->SetBranchAddress("eventNumber", &gps2_eventNumber);

  headChain->BuildIndex("header->eventNumber");
  gpsChain->BuildIndex("eventNumber");
  gpsChain2->BuildIndex("pat->realTime");


  int maxEntry=corChain->GetEntries();

  // AnitaPol::AnitaPol_t pol = AnitaPol::kHorizontal;                                                    
  AnitaPol::AnitaPol_t pol = AnitaPol::kVertical;
  Double_t sourceLat, sourceLon, sourceAlt, timeOffset;
  char cpol[100];

  Double_t phiWave, thetaWave, lower, upper;
  Double_t maxCorrTime, deltaTExpected;
  int ant1, ant2;
  headChain->GetEntry(0);
  double firstTS = header->triggerTime;
  headChain->GetEntry(headChain->GetEntries()-1);
  double lastTS = header->triggerTime;

  Double_t additionalPhi = 22.5*TMath::DegToRad();
  Double_t TwoPi = TMath::Pi()*2.;
  //  TH2D *h1 = new TH2D("h1", "", 100, firstTS, lastTS, 100, 0, 3600*24);                               
  TH2D *h1 = new TH2D("h1", "", 100, firstTS, lastTS, 100, -49.5, 50.5);
  TH1D *dHeading = new TH1D("dHeading", "", 100, -5, 5);

  for(Long64_t entry=0;entry<maxEntry;++entry) {
    corChain->GetEntry(entry);

    Long64_t headEntry = headChain->GetEntryNumberWithIndex(cor->eventNumber);
    if(headEntry < 0 ) continue;
    headChain->GetEntry(headEntry);

    Long64_t gpsEntry = gpsChain->GetEntryNumberWithIndex(cor->eventNumber);
    if(gpsEntry < 0 ) continue;
    gpsChain->GetEntry(gpsEntry);

    Long64_t gpsEntry2 = gpsChain2->GetEntryNumberWithIndex(header->triggerTime);
    if(gpsEntry2 < 0 ) continue;
    gpsChain2->GetEntry(gpsEntry2);

    if(gps_eventNumber!=gps2_eventNumber) cout << header->eventNumber <<  " " << gps2_eventNumber << endl;

    //    if ((header->triggerTime%(3600*24))!=(pat->timeOfDay/1e3)) cout << header->triggerTime%(3600*24) << " " << pat->timeOfDay/1e3 << endl;
    double tday = (header->triggerTime%(3600*24));
    h1->Fill(header->triggerTime, (tday - pat->timeOfDay/1e3) );

    dHeading->Fill((pat->heading-pat2->heading));

  }

  h1->Draw("colz");


  TCanvas *c1 = new TCanvas("c1");
  gStyle->SetOptStat(1);
  dHeading->SetTitle("Heading(eventNumber)-heading(realTime);Heading(eventNumber)-heading(realTime) [degrees];Number of events");
  dHeading->Draw();
  c1->Print("dheading.png");

}
void fillArrays(double *eventNumberIndex, double *thetaWaveIndex, double *phiWaveIndex, int *antIndex1, int *antIndex2, double *maxCorrTimeIndex, bool *adjacent){
 // char headerName[FILENAME_MAX];
  char gpsName[FILENAME_MAX];
  char corName[FILENAME_MAX];
  fGeomTool->useKurtAnita3Numbers(1);

  // RawAnitaHeader *header =0;
  Adu5Pat *pat =0;
  CorrelationSummaryAnita3 *cor=0;

  TChain *gpsChain = new TChain("adu5PatTree");
  // TChain *headChain = new TChain("headTree");
  TChain *corChain = new TChain("corTree");

  for (unsigned int run=331;run<356;++run){
      
    //    sprintf(headerName,"/unix/anita3/flight1415/root/run%d/headFile%d.root",run,run);
    // sprintf(headerName,"/unix/anita3/flight1415/root/run%d/timedHeadFile%d.root",run,run);
    //    sprintf(gpsName,"/unix/anita3/flight1415/root/run%d/gpsFile%d.root",run,run);
    sprintf(gpsName,"/unix/anita3/flight1415/root/run%d/gpsEvent%d.root",run,run);

    //    sprintf(corName, "/unix/anita3/linda/corTrees/corRun_NEW6_HPOL_%d.root", run);
    sprintf(corName, "/unix/anita3/linda/corTrees/corRun_NEW11_HPOL_%d.root", run);
    
    // headChain->Add(headerName);
    gpsChain->Add(gpsName);
    corChain->Add(corName);
    
  }
  // headChain->SetBranchAddress("header",&header);
  gpsChain->SetBranchAddress("pat",&pat);
  corChain->SetBranchAddress("cor",&cor);

  // headChain->BuildIndex("header->eventNumber");
  //  gpsChain->BuildIndex("pat->realTime");
  gpsChain->BuildIndex("eventNumber");

  int maxEntry=corChain->GetEntries();
  

  AnitaPol::AnitaPol_t pol = AnitaPol::kHorizontal;
  // AnitaPol::AnitaPol_t pol = AnitaPol::kVertical;
  Double_t sourceLat, sourceLon, sourceAlt, timeOffset;
  char cpol[100];

  if (pol == AnitaPol::kVertical){
    sourceLat = - (79 + (27.93728/60));
    sourceLon = -(112 + (6.74974/60));
    sourceAlt = 1813.42;
    timeOffset = + 92.8;
    //    timeOffset = -99756.6;
    sprintf(cpol, "VPOL");
  }else{ 
    sourceLat = - (79 + (27.94097/60));
    sourceLon = -(112 + (6.76208/60));
    sourceAlt = 1819.62;
    timeOffset = + 92.8;
    sprintf(cpol, "HPOL");
  }


  Double_t phiWave, thetaWave, lower, upper;
  Double_t maxCorrTime, deltaTExpected;
  int ant1, ant2;

  int countIndex = 0;
  int countNotsaved = 0;

  bool save = false;


  for (unsigned int ant=0;ant<MAX_ANTENNAS;++ant){
    antPhi[ant] = fGeomTool->getAntPhiPositionRelToAftFore(ant, pol);
    //    meanPhi[ant] = fGeomTool->getAntPhiPosition(ant, pol);
  }
  Double_t additionalPhi = 22.5*TMath::DegToRad();//22.5*TMath::DegToRad();
  Double_t TwoPi = TMath::Pi()*2.;
  for(Long64_t entry=0;entry<maxEntry;++entry) {
    save=false;
    corChain->GetEntry(entry);

    // Long64_t headEntry = headChain->GetEntryNumberWithIndex(cor->eventNumber);
    // if(headEntry < 0 ) continue;
    // headChain->GetEntry(headEntry);    
    
    //    Long64_t gpsEntry = gpsChain->GetEntryNumberWithIndex(header->realTime);
    Long64_t gpsEntry = gpsChain->GetEntryNumberWithIndex(cor->eventNumber);
    if(gpsEntry < 0 ) continue;
    gpsChain->GetEntry(gpsEntry);
    //gpsChain->GetEntry(headEntry);


    UsefulAdu5Pat usefulPat(pat);
    
    usefulPat.getThetaAndPhiWave(sourceLon, sourceLat, sourceAlt, thetaWave, phiWave);


    for(unsigned int corInd=0;corInd<NUM_CORRELATIONS_ANITA3;++corInd) {
      
      
      if (corInd>11 && corInd!=37 && corInd!=38 && corInd!=39) continue;

      maxCorrTime = cor->maxCorTimes[corInd];
      ant1 = cor->firstAnt[corInd];
      ant2 = cor->secondAnt[corInd];
      
      deltaTExpected=usefulPat.getDeltaTExpected(ant1, ant2, sourceLon, sourceLat, sourceAlt);

      lower = antPhi[ant1] - additionalPhi ;
      upper = antPhi[ant2] + additionalPhi ;
      if (lower<0) lower+=TwoPi;
      if (upper>TwoPi) upper-=TwoPi;

      if (lower>upper){
      	if (phiWave<TwoPi*0.5) lower-=TwoPi;
      	else upper+=TwoPi;
      }
      
      
      if ( phiWave>lower && phiWave<upper && (maxCorrTime-deltaTExpected)*(maxCorrTime-deltaTExpected)<1) {

	thetaWaveIndex[countIndex] = thetaWave;
	phiWaveIndex[countIndex] = phiWave;
	maxCorrTimeIndex[countIndex] = maxCorrTime;
	eventNumberIndex[countIndex]= cor->eventNumber;
	antIndex1[countIndex] = ant1;
	antIndex2[countIndex] = ant2;
	if (corInd>5 && corInd<12) adjacent[countIndex] = true;
	else adjacent[countIndex]=false;

	countIndex++;
	
      }
    }

	
  }

  // delete header;
  delete pat;
  delete cor;
  delete gpsChain;
  // delete headChain;
  delete corChain;


  antIndex1[countIndex] = -999;

  cout << "ARRAY FILLED! : " << countIndex << " " << countNotsaved << endl;


}