ARA ROOT v3.13 Software

calibration/antCalib/generateDeltaTs.cxx

00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 //Includes
00009 #include <iostream>
00010 #include <fstream>
00011 
00012 //AraRoot Includes
00013 #include "RawIcrrStationEvent.h"
00014 #include "RawAtriStationEvent.h"
00015 #include "UsefulAraStationEvent.h"
00016 #include "UsefulIcrrStationEvent.h"
00017 #include "UsefulAtriStationEvent.h"
00018 #include "AraGeomTool.h"
00019 #include "AraEventCalibrator.h"
00020 #include "FFTtools.h"
00021 
00022 //ROOT Includes
00023 #include "TTree.h"
00024 #include "TFile.h"
00025 #include "TGraph.h"
00026 #include "TTimeStamp.h"
00027 #include "TSystem.h"
00028 
00029 #include <map>
00030 
00031 RawIcrrStationEvent *rawIcrrEvPtr=0;
00032 RawAtriStationEvent *rawAtriEvPtr=0;
00033 RawAraStationEvent *rawEvPtr=0;
00034 UsefulIcrrStationEvent *realIcrrEvPtr=0;
00035 UsefulAtriStationEvent *realAtriEvPtr=0;
00036 UsefulAraStationEvent *realEvPtr=0;
00037 
00038 void usage(char **argv) 
00039 {  
00040   std::cout << "Usage\n" << argv[0] << " <input file>\n";
00041   std::cout << "e.g.\n" << argv[0] << " http://www.hep.ucl.ac.uk/uhen/ara/monitor/root/run1841/event1841.root\n";  
00042 }
00043 
00044 
00045 
00046 
00047 int main(int argc, char **argv) {
00048   if(argc<2) {
00049     usage(argv);
00050     return -1;
00051   }
00052 
00053 
00054   TFile *fp = TFile::Open(argv[1]);
00055   if(!fp) {
00056     std::cerr << "Can't open file\n";
00057     return -1;
00058   }
00059   TTree *eventTree = (TTree*) fp->Get("eventTree");
00060   if(!eventTree) {
00061     std::cerr << "Can't find eventTree\n";
00062     return -1;
00063   }
00064    
00065   //Now check the electronics type of the station
00066 
00067 
00068   int isIcrrEvent=0;
00069   int isAtriEvent=0;
00070 
00071   Int_t runNumber;
00072   //Check an event in the run Tree and see if it is station1 or TestBed (stationId<2)
00073   eventTree->SetBranchAddress("event",&rawEvPtr);
00074   eventTree->SetBranchAddress("run",&runNumber);
00075   eventTree->GetEntry(0);
00076 
00077   if((rawEvPtr->stationId)<2){
00078     isIcrrEvent=1;
00079     isAtriEvent=0;
00080   }
00081   else{
00082     isIcrrEvent=0;
00083     isAtriEvent=1; 
00084   }
00085   eventTree->ResetBranchAddresses();
00086 
00087   //Now set the appropriate branch addresses
00088   //The Icrr case
00089   if(isIcrrEvent){
00090 
00091     eventTree->SetBranchAddress("event", &rawIcrrEvPtr);
00092     rawEvPtr=rawIcrrEvPtr;
00093     std::cerr << "Set Branch address to Icrr\n";
00094 
00095   }
00096   //The Atri case
00097   else{
00098 
00099     eventTree->SetBranchAddress("event", &rawAtriEvPtr);
00100     rawEvPtr=rawAtriEvPtr;
00101     std::cerr << "Set Branch address to Atri\n";
00102 
00103   }
00104 
00105   //Now we set up out run list
00106   Long64_t numEntries=eventTree->GetEntries();
00107   Long64_t starEvery=numEntries/80;
00108   if(starEvery==0) starEvery++;
00109 
00110   //jpd print to screen some info
00111   std::cerr << "isAtri " << isAtriEvent << " isIcrr " << isIcrrEvent << " number of entries is " <<  numEntries << std::endl;
00112 
00113   eventTree->GetEntry(0);
00114 
00115   //Pedestal fun
00116   if(argc>2) {
00117     std::ifstream PedList(argv[2]);    
00118     int pedRun,lastPedRun=-1;
00119     char pedFileName[FILENAME_MAX];
00120     char lastPedFileName[FILENAME_MAX];
00121     while(PedList >> pedRun >> pedFileName) {
00122       if(pedRun>runNumber) {
00123         //Take the last guy
00124         if(lastPedRun==-1) {
00125           lastPedRun=pedRun;
00126           strncpy(lastPedFileName,pedFileName,FILENAME_MAX);
00127         }         
00128         break;
00129       }
00130       lastPedRun=pedRun;
00131       strncpy(lastPedFileName,pedFileName,FILENAME_MAX);
00132     }
00133     //Got the pedestal run
00134     AraEventCalibrator::Instance()->setAtriPedFile(lastPedFileName, rawAtriEvPtr->stationId);    
00135   }
00136 
00137 
00138   //  numEntries=200;
00139   for(Long64_t event=0;event<numEntries;event++) {
00140     if(event%starEvery==0) {
00141       std::cerr << "*";       
00142     }
00143 
00144     //This line gets the RawIcrr or RawAtri Event
00145     eventTree->GetEntry(event);
00146 
00147     //Here we create a useful event Either an Icrr or Atri event
00148     Int_t eventNumber=event;
00149     Int_t unixTime=1;
00150 
00151     Double_t triggerTime=0;
00152 
00153     if(isIcrrEvent){
00154       if(realIcrrEvPtr) delete realIcrrEvPtr;
00155       realIcrrEvPtr = new UsefulIcrrStationEvent(rawIcrrEvPtr, AraCalType::kLatestCalib);
00156       realEvPtr=realIcrrEvPtr;
00157       eventNumber=rawIcrrEvPtr->head.eventNumber;
00158       unixTime=rawIcrrEvPtr->head.unixTime;
00159       triggerTime=rawIcrrEvPtr->getRubidiumTriggerTimeInSec();
00160     }
00161     else if(isAtriEvent){
00162       if(realAtriEvPtr) delete realAtriEvPtr;
00163       realAtriEvPtr = new UsefulAtriStationEvent(rawAtriEvPtr, AraCalType::kLatestCalib);
00164       realEvPtr=realAtriEvPtr;
00165       eventNumber=rawAtriEvPtr->eventNumber;
00166       unixTime=rawAtriEvPtr->unixTime;
00167       triggerTime=rawAtriEvPtr->timeStamp;
00168     }
00169     int isSoftTrig=0;
00170     if(rawAtriEvPtr->numReadoutBlocks<80) isSoftTrig=1;
00171     int isCalPulser=0;
00172     if(rawAtriEvPtr->isCalpulserEvent()) isCalPulser=1;
00173     if(!isCalPulser) continue;
00174 
00175 
00176     Int_t numChannels=realEvPtr->getNumRFChannels();
00177 
00178     TGraph *gr[100]={0};
00179 
00180 
00181     for( int i=0; i<numChannels; ++i ) {
00182 
00183     }
00184   }
00185   std::cerr << "\n";
00186 
00187 
00188 }

Generated on Mon Dec 9 13:20:22 2013 for ARA ROOT v3.13 Software by doxygen 1.4.7