Privacy and Security Notice

Qevent.cc Source File

Qevent.cc

Go to the documentation of this file.
00001 #include "Qevent.h"
00002 #include <iostream>
00003 #include <math.h>
00004 
00005 #ifndef NDetMax
00006 #define NDetMax 1010
00007 #endif
00008 #ifndef NMaxHits 
00009 #define NMaxHits 1000
00010 #endif
00011 
00012 using namespace std;
00013 
00014 extern Det *rcDETRegion[2][3][4];
00015 extern Det rcDET[NDetMax];
00016 extern EUppLow operator++(enum EUppLow &rs, int );
00017 extern ERegion operator++(enum ERegion &rs, int );
00018 extern Etype operator++(enum Etype &rs, int );
00019 extern Edir operator++(enum Edir &rs, int );
00020 
00021 /*____________________________________________________________
00022 Qevent
00023 Date : 7/30/7
00024 Author : Burnham Stokes*/
00035 //____________________________________________________________
00036 Qevent::Qevent(){
00037         numevents=0;
00038         hitlist = 0;
00039 }
00040 //____________________________________________________________
00041 int Qevent::FillHits(char *eventfile){
00042         char line[256];
00043         Hit *newhit;
00044         int nhits =0;
00045         int maxchar = 256,i=0;
00046         //Detector region/type/direction identifiers
00047         enum EUppLow up_low,up_low2;
00048         enum ERegion region,region2;
00049         enum Edir dir,dir2;
00050         enum Etype type,type2;
00051 
00052         int nevent=0,nevents=0;
00053         int detecID=0;
00054         
00055         int changedetec,firstdetec = 1;
00056         Det *rd;
00057         events = fopen(eventfile,"r");
00058 
00059         while(!feof(events)){
00060                 fgets(line,maxchar,events);
00061                 if(feof(events))break;
00062                 nevent = atoi(strtok(line,"\n"));// event number
00063                 nevents++;
00064                         
00065 
00066 
00067                 fgets(line,maxchar,events);
00068                 //detecID is an integer identifying which detector is being read in
00069                 detecID = atoi(strtok(line,"\n"));
00070 
00071                 //Obtain the detector information from rcDET which is set up by Qset
00072                 up_low = rcDET[detecID].upplow;//The 'top' or 'bottom' detector
00073                 region = rcDET[detecID].region;
00074                 dir = rcDET[detecID].dir;// the wire direction for the case of drift chambers
00075                 type = rcDET[detecID].type;// the detector type 
00076 
00077                 if(firstdetec){
00078                         firstdetec = 0;
00079                         up_low2 = up_low;
00080                         region2 = region;
00081                         type2 = type;
00082                         dir2 = dir;
00083                         rd = rcDETRegion[up_low][region-1][dir];
00084                 }
00085                 else{
00086                         hitlist = NULL;
00087                         newhit = NULL;
00088                         if(up_low2 == up_low && 
00089                            region2 == region &&
00090                            type2 == type &&
00091                            dir2 == dir){
00092                                 rd = rd->nextsame;
00093                                 //cerr << "went to next" << endl;
00094                         }
00095                         else{
00096                                 rd = rcDETRegion[up_low][region-1][dir];
00097                                 up_low2 = up_low;
00098                                 region2 = region;
00099                                 type2 = type;
00100                                 dir2 = dir;
00101                         }
00102                 }
00103 
00104                 //cerr << detecID << "," << up_low << "," << region << "," << type << "," << dir << endl;
00105 
00106 
00107 
00108 /*
00109                 //String the different directions/layers in each detector
00110                 if(firstdetec){
00111                         rd = rcDETRegion[up_low][region-1][dir];
00112                         firstdetec = 0;
00113                         changedetec = detecID;
00114                 }
00115                 else if(detecID!=changedetec){
00116                         rd = rd->nextsame;
00117                         changedetec = detecID;
00118                 }
00119 */              
00120 
00121 
00122                 //number of hits
00123                 fgets(line,maxchar,events);
00124                 nhits = atoi(strtok(line,"\n"));
00125                 for(i =0;i<nhits;i++){
00126                         newhit = (Hit *)malloc( sizeof(Hit)) ;
00127                         newhit->ID = nevent;//event number
00128                         fgets(line,maxchar,events);
00129                         newhit->wire = atoi(strtok(line,"\n"));//wire number
00130                         fgets(line,maxchar,events);
00131                         newhit->Zpos = atof(strtok(line,"\n"));//Z position of wire plane(first wire for region 3)
00132                         fgets(line,maxchar,events);
00133                         newhit->rPos1 = atof(strtok(line,"\n"));//distance of hit from wire
00134                         fgets(line,maxchar,events);
00135                         newhit->rPos2 = atof(strtok(line,"\n"));//placeholder for future code
00136                         newhit->Resolution = rd->resolution;//get the spatial resolution for this hit
00137                         newhit->detec = rd;//the hit's pointer back to the detector plane
00138 
00139                         newhit->next = hitlist;//chain the hits
00140                         hitlist = newhit;
00141 
00142                         //chain the hits in each detector
00143                         newhit->nextdet = rd->hitbydet;
00144                         rd->hitbydet = newhit;  
00145                 }
00146         }
00147         
00148         return 1;
00149 }
00150 
00151 //____________________________________________________________

Generated on Fri Jan 11 22:33:59 2008 by  doxygen 1.4.6