FEDRA emulsion software from the OPERA Collaboration
ProcessRawData Class Reference

#include <ProcessRawData.h>

Collaboration diagram for ProcessRawData:

Public Member Functions

bool dumpCatalogInEdbStructure ()
 
bool dumpFragmentInEdbStructure ()
 
void filterTracks (bool filterTracks)
 
const char * getCatalogName ()
 
bool getClOption ()
 
bool getFilterTracksOption ()
 
const char * getFragmentName ()
 
unsigned int getFragmentsNumberFromCatalog ()
 
const char * getRootName ()
 
void initCatalog ()
 
void initFragment ()
 
int makeTracksPlot (const char *plotFileName)
 
 ProcessRawData ()
 
bool readCatalog ()
 
bool readFragment ()
 
void setCatalogName (std::string fileName)
 
void setClOption (bool noCl)
 
void setFilterTrackOption (bool filterTracks)
 
void setFragmentName (std::string fileName)
 
void setRootName (std::string fileName)
 
 ~ProcessRawData ()
 

Private Attributes

Catalog_catalog
 
std::string _catFileName
 
bool _clusters
 
bool _filterTracks
 
std::string _fragFileName
 
Fragment_fragment
 
std::string _outputRootFileName
 
EdbRun_run
 

Constructor & Destructor Documentation

◆ ProcessRawData()

ProcessRawData::ProcessRawData ( )
5{
6 _run = 0;
7 _fragment = 0;
8 _catalog = 0;
9 _clusters = false;
10 _filterTracks = false;
11}
EdbRun * _run
Definition: ProcessRawData.h:33
Fragment * _fragment
Definition: ProcessRawData.h:35
bool _clusters
Definition: ProcessRawData.h:39
Catalog * _catalog
Definition: ProcessRawData.h:34
bool _filterTracks
Definition: ProcessRawData.h:40

◆ ~ProcessRawData()

ProcessRawData::~ProcessRawData ( )
14{
15 if (_run) { _run->Close(); delete _run; _run=0; }
16 if (_fragment) { delete _fragment; _fragment=0; }
17 if (_catalog) { delete _catalog; _catalog = 0; }
18}
void Close()
Definition: EdbRun.cxx:439

Member Function Documentation

◆ dumpCatalogInEdbStructure()

bool ProcessRawData::dumpCatalogInEdbStructure ( )
743{
744 if(!_run) _run = new EdbRun(_outputRootFileName.c_str(), "RECREATE" );
745
746// _run->GetTree()->SetMaxTreeSize(static_cast<long long>(10e9));
748 Header->SetFlag(0,2);
749 Header->SetFlag(1,1);
750 Header->SetFlag(2,1);
751 Header->SetLimits(static_cast<float>(_catalog->getXmin()),
752 static_cast<float>(_catalog->getXmax()),
753 static_cast<float>(_catalog->getYmin()),
754 static_cast<float>(_catalog->getYmax()));
755 //int index = _catalog->findConfig("Vertigo");
756 std::string retValue = _catalog->getConfigValue(_catalog->findConfig("Vertigo"),"VLayers");
757
758
759 Header->SetArea(static_cast<int>(_catalog->getXviews()*_catalog->getYviews()),
760 static_cast<float>(_catalog->getXstep()),static_cast<float>(_catalog->getYstep())
761 , atoi(retValue.c_str()),atoi(retValue.c_str()), 0);
762
763 Header->SetCCD(atoi(_catalog->getConfigValue(_catalog->findConfig("Objective"),"Width").c_str()),
764 atoi(_catalog->getConfigValue(_catalog->findConfig("Objective"),"Height").c_str()),
765 -999, // physical pixel size in microns along X
766 -999, // physical pixel size in microns along Y
767 "", // es. "Dalsa CAD4"
768 ""); // es. "Bologna"
769 Header->SetObjective(-999, // magnification
770 static_cast<float>(atof(_catalog->getConfigValue(_catalog->findConfig("Objective"),"Width").c_str())*
771 fabs(atof(_catalog->getConfigValue(_catalog->findConfig("Objective"),"PixelToMicronX").c_str()))),
772 0,0,
773 static_cast<float>(atof(_catalog->getConfigValue(_catalog->findConfig("Objective"),"Height").c_str())*
774 fabs(atof(_catalog->getConfigValue(_catalog->findConfig("Objective"),"PixelToMicronY").c_str()))),
775 0,0,
776 "", // es. "Nikon CFI - oil"
777 ""); // es, "50x"
778 float vStepTop = static_cast<float>(atof(_catalog->getConfigValue(_catalog->findConfig("Vertigo"),"TopStep").c_str()));
779 float vStepBottom = static_cast<float>(atof(_catalog->getConfigValue(_catalog->findConfig("Vertigo"),"BottomStep").c_str()));
780 float shr = static_cast<float>(atof(_catalog->getConfigValue(_catalog->findConfig("Vertigo"),"Shrinkage").c_str()));
781 float base = static_cast<float>(atof(_catalog->getConfigValue(_catalog->findConfig("Vertigo"),"BaseThickness").c_str()));
782 Header->SetPlate(-999, // plate ID
783 vStepTop*shr,
784 base,
785 vStepBottom*shr,shr,shr,
786 "", // es. "Test Plate"
787 "");
788 // Store the catalog file as TObjString
789 TObjString objstr ;
790 int i, ch;
791 FILE *stream;
792 if( (stream = fopen( _catFileName.c_str(), "rb" )) == NULL ) return false;
793 ch = fgetc( stream );
794 for( i=0; feof( stream ) == 0 ; i++ )
795 {
796 objstr.String().Append( ch );
797 ch = fgetc( stream );
798 }
799 fclose( stream );
800 objstr.Write("catalog");
801 _run->Save() ;
802 //_run->Close();
803 return true;
804}
Expr< UnaryOp< Fabs< T >, Expr< A, T, D >, T >, T, D > fabs(const Expr< A, T, D > &rhs)
Definition: UnaryOperators.hh:96
double getXstep()
Definition: Catalog.h:45
double getYmin()
Definition: Catalog.h:43
double getXmax()
Definition: Catalog.h:42
double getXmin()
Definition: Catalog.h:41
double getYmax()
Definition: Catalog.h:44
double getYstep()
Definition: Catalog.h:46
unsigned int getYviews()
Definition: Catalog.h:40
unsigned int getXviews()
Definition: Catalog.h:39
std::string getConfigValue(int index, std::string configName)
Definition: Catalog.cpp:67
int findConfig(std::string configName)
Definition: Catalog.cpp:21
Definition: EdbRunHeader.h:95
Definition: EdbRun.h:75
void Save()
Definition: EdbRun.cxx:424
EdbRunHeader * GetHeader() const
Definition: EdbRun.h:138
std::string _catFileName
Definition: ProcessRawData.h:36
std::string _outputRootFileName
Definition: ProcessRawData.h:38
fclose(pFile)
Definition: tlg2couples.C:65
#define NULL
Definition: nidaqmx.h:84

◆ dumpFragmentInEdbStructure()

bool ProcessRawData::dumpFragmentInEdbStructure ( )
808{
809 if(!_run) {
810 if ( gSystem->AccessPathName( _outputRootFileName.c_str() ) )
811 _run = new EdbRun( _outputRootFileName.c_str(), "RECREATE" );
812 else
813 _run = new EdbRun( _outputRootFileName.c_str(), "UPDATE" );
814 }
815 //run->GetTree()->SetMaxTreeSize(static_cast<long long>(10e9));
816
817 EdbView* edbView = _run->GetView();
818 //EdbSegment* edbSegment = new EdbSegment(0,0,0,0,0,0,0,0);
819 std::auto_ptr<EdbSegment> edbSegment( new EdbSegment(0,0,0,0,0,0,0,0) );
820
821 int v, t, p; // v=view, s=side, t=track, p=point
822 int tracks; // number of tracks in the fragment
823 int fclusters; // number of clusters in the fragment
824 int vclusters; // number of clusters in the view
825 float dz ; // z-length of the track segment
826 int tr_clusters; // number of cluster of the track
827 int puls ; // ePuls = (number of clusters ) OR (sum of clust areas)*1000 + (number of clusters)
828 float volume = 0;
829 int frameId = 0;
830 tracks = 0;
831 fclusters = 0;
833 for (v = 0; v < _fragment->getViews(); v++) //TOP
834 {
835 View *rwdView = _fragment->getView(v);
836 Side *topSide = rwdView->getTopSide();
837 vclusters = 0;
838 tracks+=topSide->getTracks();
839 edbView->Clear();
840 EdbViewHeader* edbViewHeader = edbView->GetHeader();
841 edbViewHeader->SetAffine(static_cast<float>(topSide->getMXX()),
842 static_cast<float>(topSide->getMXY()),static_cast<float>(topSide->getMYX()),
843 static_cast<float>(topSide->getMYY()),static_cast<float>(topSide->getMappedFovPosX()),
844 static_cast<float>(topSide->getMappedFovPosY()));
845
846 edbViewHeader->SetAreaID(_fragment->getIndex());
847 edbViewHeader->SetCoordXY(static_cast<float>(topSide->getStageFovPosX()), static_cast<float>(topSide->getStageFovPosY()));
848 edbViewHeader->SetCoordZ(static_cast<float>(topSide->getTopZ()),static_cast<float>(topSide->getBottomZ()),
849 static_cast<float>(rwdView->getBottomSide()->getTopZ()),static_cast<float>(rwdView->getBottomSide()->getBottomZ())); // NON capito i relevant Z
850
851 edbViewHeader->SetNframes(topSide->getLayers(),0);
852 edbViewHeader->SetNsegments(topSide->getTracks());
853 edbViewHeader->SetViewID(rwdView->getId());
854 edbViewHeader->SetColRow(rwdView->getTileX() ,rwdView->getTileY() );
855 int nframes = topSide->getLayers();
856 for( int nlvl=0; nlvl<nframes; nlvl++ )
857 {
858 edbView->AddFrame(nlvl,static_cast<float>(topSide->getLayerAt(nlvl)->zLayer),
859 topSide->getLayerAt(nlvl)->grains);
860 }
861 for (t = 0; t < topSide->getTracks(); t++) {
862 Track *tr = topSide->getTrackAt(t);
863 tr_clusters = tr->getCount();
864 puls = tr->getCount(); // dovrei mettere l'if per le opzioni di rwc2edb
865 if (tr->getGrains().size()!=0)
866 dz = static_cast<float>(tr->getGrains().at(0).z - tr->getGrains().at(tr_clusters-1).z);
867 else dz = 0.;
868
869 edbSegment->Set( static_cast<float>(tr->getX()),static_cast<float>(tr->getY()),
870 static_cast<float>(tr->getZ()),static_cast<float>(tr->getSX()),static_cast<float>(tr->getSY()),
871 dz, 0 , puls, t);
872 edbSegment->SetSigma(static_cast<float>(tr->getSigma()),-999.);
873 if (tr->getGrains().size()!=0 ) { // fixare opzioni nocl
874 volume = 0;
875 frameId = 0;
876 }
877 if (_clusters)
878 {
879 for ( p=0; p<tr_clusters;p++) {
880 for(int nlvl=frameId;nlvl<nframes;nlvl++) {
881 if(tr->getGrains().at(p).z == rwdView->getTopSide()->getLayerAt(nlvl)->zLayer) {
882 frameId=nlvl;
883 break;
884 }
885 }
886
887 edbView->AddCluster( static_cast<float>(tr->getGrains().at(p).x),
888 static_cast<float>(tr->getGrains().at(p).y),
889 static_cast<float>(tr->getGrains().at(p).z),
890 static_cast<float>(tr->getGrains().at(p).area),
891 volume,
892 frameId,
893 0,t);
894
895 }
896 }
897 edbViewHeader->SetNclusters(vclusters);
898 edbView->AddSegment(edbSegment.get()) ;
899 vclusters += tr_clusters;
900 } // end of tracks (t)
901 _run->AddView(edbView);
902 fclusters += vclusters;
903 } //end of views (v)
904
905
906
907
908 for (v = 0; v < _fragment->getViews(); v++) //BOTTOM
909 {
910 View *rwdView = _fragment->getView(v);
911 Side *bottomSide = rwdView->getBottomSide();
912 vclusters = 0;
913 tracks+=bottomSide->getTracks();
914 edbView->Clear();
915 EdbViewHeader* edbViewHeader = edbView->GetHeader();
916 edbViewHeader->SetAffine(static_cast<float>(bottomSide->getMXX()),static_cast<float>(bottomSide->getMXY()),
917 static_cast<float>(bottomSide->getMYX()),static_cast<float>(bottomSide->getMYY()),
918 static_cast<float>(bottomSide->getMappedFovPosX()),static_cast<float>(bottomSide->getMappedFovPosY()));
919 //edbViewHeader->SetAreaID(run->GetHeader()->GetNareas());
920 edbViewHeader->SetAreaID(_fragment->getIndex());
921 edbViewHeader->SetCoordXY(static_cast<float>(bottomSide->getStageFovPosX()), static_cast<float>(bottomSide->getStageFovPosY()));
922 edbViewHeader->SetCoordZ(static_cast<float>(rwdView->getTopSide()->getTopZ()),static_cast<float>(rwdView->getTopSide()->getBottomZ()),
923 static_cast<float>(rwdView->getBottomSide()->getTopZ()),static_cast<float>(rwdView->getBottomSide()->getBottomZ())); // NON capito i relevant Z
924 //edbViewHeader->SetNframes(bottomSide->getLayers(),0);
925 edbViewHeader->SetNframes(0,bottomSide->getLayers());
926 edbViewHeader->SetNsegments(bottomSide->getTracks());
927 edbViewHeader->SetViewID(rwdView->getId());
928 edbViewHeader->SetColRow(rwdView->getTileX() ,rwdView->getTileY() );
929 int nframes = bottomSide->getLayers();
930 for( int nlvl=0; nlvl<nframes; nlvl++ )
931 {
932 edbView->AddFrame(nlvl,static_cast<float>(bottomSide->getLayerAt(nlvl)->zLayer),
933 bottomSide->getLayerAt(nlvl)->grains);
934 }
935 for (t = 0; t < bottomSide->getTracks(); t++) {
936 Track *tr = bottomSide->getTrackAt(t);
937 tr_clusters = tr->getCount();
938 puls = tr->getCount(); // dovrei mettere l'if per le opzioni di rwc2edb
939 if (tr->getGrains().size()!=0)
940 dz = static_cast<float>(tr->getGrains().at(0).z - tr->getGrains().at(tr_clusters-1).z);
941 else dz = 0;
942
943 edbSegment->Set( static_cast<float>(tr->getX()),static_cast<float>(tr->getY()),
944 static_cast<float>(tr->getZ()),static_cast<float>(tr->getSX()),
945 static_cast<float>(tr->getSY()), dz, 1 , puls, t);
946 edbSegment->SetSigma(static_cast<float>(tr->getSigma()),-999.);
947 if (tr->getGrains().size()!=0 ) { // fixare opzioni nocl
948 volume = 0;
949 frameId = 0;
950 }
951 if (_clusters)
952 {
953 for ( p=0; p<tr_clusters;p++) {
954 for(int nlvl=frameId;nlvl<nframes;nlvl++) {
955 if(tr->getGrains().at(p).z == rwdView->getTopSide()->getLayerAt(nlvl)->zLayer) {
956 frameId=nlvl;
957 break;
958 }
959 }
960 edbView->AddCluster( static_cast<float>(tr->getGrains().at(p).x),
961 static_cast<float>(tr->getGrains().at(p).y),
962 static_cast<float>(tr->getGrains().at(p).z),
963 static_cast<float>(tr->getGrains().at(p).area),
964 volume,
965 frameId,
966 1,t);
967 }
968 }
969 edbViewHeader->SetNclusters(vclusters);
970 edbView->AddSegment(edbSegment.get()) ;
971 vclusters += tr_clusters;
972 } // end of tracks (t)
973 _run->AddView(edbView);
974 fclusters += vclusters;
975 } //end of views (v)
976
977// _run->Close();
978 std::cout<< "Fragment: " << _fragment->getIndex() << "\tmicrotracks: " << tracks << "\tclusters: " << fclusters << std::endl;
979 return true;
980}
brick dz
Definition: RecDispMC.C:107
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
void SetNareas(int n)
Definition: EdbRunHeader.h:134
Int_t GetNareas() const
Definition: EdbRunHeader.h:148
EdbView * GetView() const
Definition: EdbRun.h:110
void AddView()
Definition: EdbRun.cxx:305
segment of the track
Definition: EdbSegment.h:63
view identification
Definition: EdbView.h:26
void SetColRow(int col, int row)
Definition: EdbView.h:105
void SetCoordZ(float z1, float z2, float z3, float z4)
Definition: EdbView.h:102
void SetNsegments(int nseg)
Definition: EdbView.h:86
void SetAreaID(int id)
Definition: EdbView.h:100
void SetViewID(int id)
Definition: EdbView.h:99
void SetNclusters(int nclu)
Definition: EdbView.h:85
void SetNframes(int top, int bot)
Definition: EdbView.h:104
void SetAffine(float a11, float a12, float a21, float a22, float b1, float b2)
Definition: EdbView.h:67
void SetCoordXY(float x, float y)
Definition: EdbView.h:101
Base scanning data object: entry into Run tree.
Definition: EdbView.h:134
EdbViewHeader * GetHeader() const
Definition: EdbView.h:163
EdbSegment * AddSegment(float x, float y, float z, float tx, float ty, float dz=0, int side=0, int puls=0, int id=-1)
Definition: EdbView.h:231
EdbCluster * AddCluster(EdbCluster *c)
Definition: EdbView.h:225
void AddFrame(int id, float z, int ncl=0, int npix=0)
Definition: EdbView.cxx:268
void Clear()
Definition: EdbView.cxx:79
unsigned int getIndex()
Definition: Fragment.h:32
View * getView(int index)
Definition: Fragment.h:35
int getViews()
Definition: Fragment.h:34
Definition: Side.h:11
double getTopZ() const
Definition: Side.h:59
int getLayers() const
Definition: Side.h:66
double getBottomZ() const
Definition: Side.h:60
double getMXX() const
Definition: Side.h:67
double getMappedFovPosX() const
Definition: Side.h:64
Track * getTrackAt(int id)
Definition: Side.h:76
double getStageFovPosY() const
Definition: Side.h:63
double getMYX() const
Definition: Side.h:69
int getTracks() const
Definition: Side.h:80
double getMXY() const
Definition: Side.h:68
double getMappedFovPosY() const
Definition: Side.h:65
Layer * getLayerAt(int id)
Definition: Side.h:75
double getStageFovPosX() const
Definition: Side.h:62
double getMYY() const
Definition: Side.h:70
Definition: Track.h:10
Side getBottomSide() const
Definition: View.h:28
int getTileX() const
Definition: View.h:29
int getId() const
Definition: View.h:31
int getTileY() const
Definition: View.h:30
Side getTopSide() const
Definition: View.h:27
TTree * t
Definition: check_shower.C:4
TTree * tracks
Definition: check_tr.C:19
Definition: tlg2couples.C:89
unsigned int grains
Definition: Struct.h:28
double zLayer
Definition: Struct.h:29
p
Definition: testBGReduction_AllMethods.C:8

◆ filterTracks()

void ProcessRawData::filterTracks ( bool  filterTracks)
inline
void filterTracks(bool filterTracks)
Definition: ProcessRawData.h:53

◆ getCatalogName()

const char * ProcessRawData::getCatalogName ( )
inline
54{return _catFileName.c_str();}

◆ getClOption()

bool ProcessRawData::getClOption ( )
inline
57{return _clusters;}

◆ getFilterTracksOption()

bool ProcessRawData::getFilterTracksOption ( )
inline
58{return _filterTracks;}

◆ getFragmentName()

const char * ProcessRawData::getFragmentName ( )
inline
55{return _fragFileName.c_str();}
std::string _fragFileName
Definition: ProcessRawData.h:37

◆ getFragmentsNumberFromCatalog()

unsigned int ProcessRawData::getFragmentsNumberFromCatalog ( )
33{
34 if (_catalog)
35 return _catalog->getNfragments();
36 return 0;
37}
unsigned int getNfragments()
Definition: Catalog.h:47

◆ getRootName()

const char * ProcessRawData::getRootName ( )
inline
56{return _outputRootFileName.c_str();}

◆ initCatalog()

void ProcessRawData::initCatalog ( )
21{
22 if (_catalog)
23 delete _catalog;
24 _catalog = new Catalog();
25}
Definition: Catalog.h:7

◆ initFragment()

void ProcessRawData::initFragment ( )
27{
28 if (_fragment)
29 delete _fragment;
30 _fragment = new Fragment();
31}
Int_t Fragment
Definition: tlg2couples.C:134

◆ makeTracksPlot()

int ProcessRawData::makeTracksPlot ( const char *  plotFileName)
984{
985 int nViews = _fragment->getViews();
986 int counter = 0;
987 for (int i = 0; i < nViews; i++)
988 {
989 counter += _fragment->getView(i)->getTopSide()->getTracks();
990 counter += _fragment->getView(i)->getBottomSide()->getTracks();
991 }
992 if (counter == 0)
993 return 0;
994
995 double x0,y0,z0,tx,ty,dz,sigma; // segments parameters
996 unsigned int side,puls,id; // segments parameters
997 unsigned int areasum; // segments parameters
998 double meanDeltaTheta3D; // mean 3D angular variation (computed between adiacent clusters)
999 double sigmaDeltaTheta3D; // sigma 3D angular variation (computed between adiacent clusters)
1000 double meanDeltaThetaXZ; // mean 2D angular variation - plane XZ
1001 double sigmaDeltaThetaXZ; // sigma 2D angular variation - plane XZ
1002 double meanDeltaThetaYZ; // mean 2D angular variation - plane YZ
1003 double sigmaDeltaThetaYZ; // sigma 2D angular variation - plane YZ
1004 double meanDistanceClustersTo3DLine; // mean Distance beetween cluster and 3D line fit
1005 double meanGapClusterToCluster; // mean gap beetween adiacent clusters
1006 double mx, mxSigma, qx, qxSigma, rx, xCov, xChi2; // 2D fit parameters for XZ plane
1007 double my, mySigma, qy, qySigma, ry, yCov, yChi2; // 2D fit parameters for YZ plane
1008
1009 TTree *tree = 0;
1010 TFile *outf = 0;
1011
1012 if(gSystem->AccessPathName(plotFileName))
1013 {
1014
1015 outf = new TFile(plotFileName,"UPDATE"); // update an existing file (to super-impose all fragments in the same file)
1016 tree = new TTree("plots","plots");
1017
1018 tree->Branch("x0",&x0,"x0/D");
1019 tree->Branch("y0",&y0,"y0/D");
1020 tree->Branch("z0",&z0,"z0/D");
1021 tree->Branch("tx",&tx,"tx/D");
1022 tree->Branch("ty",&ty,"ty/D");
1023 tree->Branch("dz",&dz,"dz/D");
1024 tree->Branch("side",&side,"side/i");
1025 tree->Branch("puls",&puls,"puls/i");
1026 tree->Branch("id",&id,"id/i");
1027 tree->Branch("areasum",&areasum,"areasum/i");
1028 tree->Branch("sigma",&sigma,"sigma/D");
1029 tree->Branch("meanDeltaTheta3D",&meanDeltaTheta3D,"meanDeltaTheta3D/D");
1030 tree->Branch("sigmaDeltaTheta3D",&sigmaDeltaTheta3D,"sigmaDeltaTheta3D/D");
1031 tree->Branch("meanDeltaThetaXZ",&meanDeltaThetaXZ,"meanDeltaThetaXZ/D");
1032 tree->Branch("sigmaDeltaThetaXZ",&sigmaDeltaThetaXZ,"sigmaDeltaThetaXZ/D");
1033 tree->Branch("meanDeltaThetaYZ",&meanDeltaThetaYZ,"meanDeltaThetaYZ/D");
1034 tree->Branch("sigmaDeltaThetaYZ",&sigmaDeltaThetaYZ,"sigmaDeltaThetaYZ/D");
1035 tree->Branch("meanDistanceClustersTo3DLine",&meanDistanceClustersTo3DLine,"meanDistanceClustersTo3DLine/D");
1036 tree->Branch("meanGapClusterToCluster",&meanGapClusterToCluster,"meanGapClusterToCluster/D");
1037 tree->Branch("mx",&mx,"mx/D");
1038 tree->Branch("mxSigma",&mxSigma,"mxSigma/D");
1039 tree->Branch("qx",&qx,"qx/D");
1040 tree->Branch("qxSigma",&qxSigma,"qxSigma/D");
1041 tree->Branch("xCov",&xCov,"xCov/D");
1042 tree->Branch("xChi2",&xChi2,"xChi2/D");
1043 tree->Branch("rx",&rx,"rx/D");
1044 tree->Branch("my",&my,"my/D");
1045 tree->Branch("qy",&qy,"qy/D");
1046 tree->Branch("mySigma",&mySigma,"mySigma/D");
1047 tree->Branch("qySigma",&qySigma,"qySigma/D");
1048 tree->Branch("yCov",&yCov,"yCov/D");
1049 tree->Branch("yChi2",&yChi2,"yChi2/D");
1050 tree->Branch("ry",&ry,"ry/D");
1051
1052 }
1053 else
1054 {
1055 outf = new TFile(plotFileName,"UPDATE");
1056 tree = (TTree*)(outf->Get("plots"));
1057 tree->SetBranchAddress("x0",&x0);
1058 tree->SetBranchAddress("y0",&y0);
1059 tree->SetBranchAddress("z0",&z0);
1060 tree->SetBranchAddress("tx",&tx);
1061 tree->SetBranchAddress("ty",&ty);
1062 tree->SetBranchAddress("dz",&dz);
1063 tree->SetBranchAddress("side",&side);
1064 tree->SetBranchAddress("puls",&puls);
1065 tree->SetBranchAddress("id",&id);
1066 tree->SetBranchAddress("areasum",&areasum);
1067 tree->SetBranchAddress("sigma",&sigma);
1068 tree->SetBranchAddress("meanDeltaTheta3D",&meanDeltaTheta3D);
1069 tree->SetBranchAddress("sigmaDeltaTheta3D",&sigmaDeltaTheta3D);
1070 tree->SetBranchAddress("meanDeltaThetaXZ",&meanDeltaThetaXZ);
1071 tree->SetBranchAddress("sigmaDeltaThetaXZ",&sigmaDeltaThetaXZ);
1072 tree->SetBranchAddress("meanDeltaThetaYZ",&meanDeltaThetaYZ);
1073 tree->SetBranchAddress("sigmaDeltaThetaYZ",&sigmaDeltaThetaYZ);
1074 tree->SetBranchAddress("meanDistanceClustersTo3DLine",&meanDistanceClustersTo3DLine);
1075 tree->SetBranchAddress("meanGapClusterToCluster",&meanGapClusterToCluster);
1076 tree->SetBranchAddress("mx",&mx);
1077 tree->SetBranchAddress("qx",&qx);
1078 tree->SetBranchAddress("xChi2",&xChi2);
1079 tree->SetBranchAddress("rx",&rx);
1080 tree->SetBranchAddress("my",&my);
1081 tree->SetBranchAddress("qy",&qy);
1082 tree->SetBranchAddress("yChi2",&yChi2);
1083 tree->SetBranchAddress("ry",&ry);
1084 }
1085
1086
1087 std::cout << "Saving plots into the file " << plotFileName << ": " << std::setw(2) << std::setprecision(2) << 0 << "%" << std::flush;;
1088 std::cout << "\b\b\b";
1089
1090
1091 for (int i = 0; i < nViews; i++)
1092 {
1093 View *view = _fragment->getView(i);
1094 Side *top = view->getTopSide();
1095 Side *bottom = view->getBottomSide();
1096 int nTracksTop = top->getTracks();
1097 int nTracksBottom = bottom->getTracks();
1098
1099 for (int t = 0; t < nTracksTop; t++)
1100 {
1101 Track *tr = top->getTrackAt(t);
1102 x0 = tr->getX();
1103 y0 = tr->getY();
1104 z0 = tr->getZ();
1105 tx = tr->getSX();
1106 ty = tr->getSY();
1107 sigma = tr->getSigma();
1108 dz = tr->dz;
1109 side = 1;
1110 puls = tr->getCount();
1111 id = t;
1112 areasum = tr->getAreaSum();
1113 meanDeltaTheta3D = tr->meanDeltaTheta3D;
1114 sigmaDeltaTheta3D = tr->sigmaDeltaTheta3D;
1115 meanDeltaThetaXZ = tr->meanDeltaThetaXZ;
1116 sigmaDeltaThetaXZ = tr->sigmaDeltaThetaXZ;
1117 meanDeltaThetaYZ = tr->meanDeltaThetaYZ;
1118 sigmaDeltaThetaYZ = tr->sigmaDeltaThetaYZ;
1119 meanDistanceClustersTo3DLine = tr->meanDistanceClustersTo3DLine;
1120 meanGapClusterToCluster = tr->meanGapClusterToCluster;
1121 mx = tr->mx;
1122 qx = tr->qx;
1123 rx = tr->rx;
1124 xChi2 = tr->xChi2;
1125 my = tr->my;
1126 qy = tr->qy;
1127 ry = tr->ry;
1128 yChi2 = tr->yChi2;
1129 tree->Fill();
1130 counter++;
1131 }
1132
1133 for (int b = 0; b < nTracksBottom; b++)
1134 {
1135 Track *tr = bottom->getTrackAt(b);
1136 x0 = tr->getX();
1137 y0 = tr->getY();
1138 z0 = tr->getZ();
1139 tx = tr->getSX();
1140 ty = tr->getSY();
1141 sigma = tr->getSigma();
1142 dz = tr->dz;
1143 side = 2;
1144 puls = tr->getCount();
1145 id = b;
1146 areasum = tr->getAreaSum();
1147 meanDeltaTheta3D = tr->meanDeltaTheta3D;
1148 sigmaDeltaTheta3D = tr->sigmaDeltaTheta3D;
1149 meanDeltaThetaXZ = tr->meanDeltaThetaXZ;
1150 sigmaDeltaThetaXZ = tr->sigmaDeltaThetaXZ;
1151 meanDeltaThetaYZ = tr->meanDeltaThetaYZ;
1152 sigmaDeltaThetaYZ = tr->sigmaDeltaThetaYZ;
1153 meanDistanceClustersTo3DLine = tr->meanDistanceClustersTo3DLine;
1154 meanGapClusterToCluster = tr->meanGapClusterToCluster;
1155 mx = tr->mx;
1156 qx = tr->qx;
1157 rx = tr->rx;
1158 xChi2 = tr->xChi2;
1159 my = tr->my;
1160 qy = tr->qy;
1161 ry = tr->ry;
1162 yChi2 = tr->yChi2;
1163 tree->Fill();
1164 counter++;
1165
1166 }
1167 std::cout << std::setw(2) << std::setprecision(2) << int((double) i/(nViews-1)*100) << "%" << std::flush;
1168 std::cout << "\b\b\b";
1169 }
1170 std::cout << std::endl;
1171
1172 //outf->Write();
1173 //tree->Write();
1174 tree->Write("", TObject::kOverwrite);
1175 outf->Close();
1176 return counter;
1177
1178}
brick z0
Definition: RecDispMC.C:106
UInt_t id
Definition: tlg2couples.C:117

◆ readCatalog()

bool ProcessRawData::readCatalog ( )
39{
40 std::ifstream infile(_catFileName.c_str(),std::ios::binary);
41
42 if (infile.fail())
43 {
44 std::cout << "Failed to open file" << std::endl;
45 return false;
46 }
48
49 char byteInfo;
50 infile.read((char*)&byteInfo,SIZE_OF_CHAR);
51 unsigned short headerFormat;
52 infile.read((char*)&headerFormat,SIZE_OF_UNSIGNED_SHORT_INT);
53 //if (something) format not supported!
55 infile.read((char*)&(id.part0),SIZE_OF_INT);
56 infile.read((char*)&(id.part1),SIZE_OF_INT);
57 infile.read((char*)&(id.part2),SIZE_OF_INT);
58 infile.read((char*)&(id.part3),SIZE_OF_INT);
59
60 std::cout << "infoType: " << byteInfo << "\nheaderFormat: " << headerFormat << std::endl;
61 std::cout << "Part0: " << id.part0 <<
62 "\nPart1: " << id.part1 <<
63 "\nPart2: " << id.part2 <<
64 "\nPart3: " << id.part3 << std::endl;
65
67 double minx,miny,maxx,maxy,stepx,stepy;
68 unsigned int xviews,yviews,nFragments;
69 if (headerFormat == 1795) // NormalDouble = 0x705
70 {
71
72 infile.read((char*)&(minx),SIZE_OF_DOUBLE);
73 _catalog->setXmin(minx);
74 infile.read((char*)&(maxx),SIZE_OF_DOUBLE);
75 _catalog->setXmax(maxx);
76 infile.read((char*)&(miny),SIZE_OF_DOUBLE);
77 _catalog->setYmin(miny);
78 infile.read((char*)&(maxy),SIZE_OF_DOUBLE);
79 _catalog->setYmax(maxy);
80 infile.read((char*)&(stepx),SIZE_OF_DOUBLE);
81 _catalog->setXstep(stepx);
82 infile.read((char*)&(stepy),SIZE_OF_DOUBLE);
83 _catalog->setYstep(stepy);
84 infile.read((char*)&(xviews),SIZE_OF_UNSIGNED_INT);
85 _catalog->setXviews(xviews);
86 infile.read((char*)&(yviews),SIZE_OF_UNSIGNED_INT);
87 _catalog->setYviews(yviews);
88 infile.read((char*)&(nFragments),SIZE_OF_UNSIGNED_INT);
89 _catalog->setNfragments(nFragments);
90 _catalog->initFragmentIndexes(yviews,xviews);
92 set->name = "Setup Info";
93 //unsigned char readUInt;
94 unsigned int readUInt;
95 infile.read((char*)&(readUInt),SIZE_OF_UNSIGNED_INT);
96 set->length = readUInt;
97 for (unsigned int i = 0; i < set->length; i++)
98 {
100 std::string className; infile.read((char*)(&className),64);
101 std::string name; infile.read((char*)(&name),64);
102 infile.read((char*)&(readUInt),SIZE_OF_UNSIGNED_INT);
103 cfg.className = className;
104 cfg.name = name;
105 cfg.length = readUInt;
106 std::cout << " === ClassName === \n\n" << className.c_str() <<
107 "\n\n ==== name === \n\n" << name.c_str() << std::endl;
108 for (unsigned int j=0; j<cfg.length; j++)
109 {
111 std::string name; infile.read((char*)(&name),64);
112 std::string value; infile.read((char*)(&value),64);
113 keys->name = name;
114 keys->value = value;
115 cfg.keys.push_back(*keys);
116 }
117 }
118 for (unsigned int i = 0; i < _catalog->getXviews(); i++)
119 {
120 for (unsigned int j = 0; i < _catalog->getYviews(); j++)
121 {
122 unsigned int value; infile.read((char*)(&value),SIZE_OF_UNSIGNED_INT);
123 _catalog->setFragmentIndexes(j,i,value);
124 }
125 }
126 std::string reservedBytes; infile.read((char*)(&reservedBytes),256);
127
128 }
129 else // --- USED IN SCANGRID MODE ----
130 {
131 infile.read((char*)&(minx),SIZE_OF_INT);
132 _catalog->setXmin(minx);
133 infile.read((char*)&(maxx),SIZE_OF_INT);
134 _catalog->setXmax(maxx);
135 infile.read((char*)&(miny),SIZE_OF_INT);
136 _catalog->setYmin(miny);
137 infile.read((char*)&(maxy),SIZE_OF_INT);
138 _catalog->setYmax(maxy);
139 infile.read((char*)&(stepx),SIZE_OF_INT);
140 _catalog->setXstep(stepx);
141 infile.read((char*)&(stepy),SIZE_OF_INT);
142 _catalog->setYstep(stepy);
143 infile.read((char*)&(xviews),SIZE_OF_UNSIGNED_INT);
144 _catalog->setXviews(xviews);
145 infile.read((char*)&(yviews),SIZE_OF_UNSIGNED_INT);
146 _catalog->setYviews(yviews);
147 infile.read((char*)&(nFragments),SIZE_OF_UNSIGNED_INT);
148 _catalog->setNfragments(nFragments);
149 _catalog->initFragmentIndexes(yviews,xviews);
151 set->name = "Setup Info";
152 unsigned int readUInt;
153 infile.read((char*)&(readUInt),SIZE_OF_UNSIGNED_INT);
154 set->length = readUInt;
155 std::cout << "nFragments: " << nFragments << std::endl;
156 for (unsigned int i = 0; i < set->length; i++)
157 {
159 char className[65], name[65], value[65];
160 infile.read((char*)(&className),64);
161 infile.read((char*)(&name),64);
162 cfg.className = className;
163 cfg.name = name;
164 //long a;
165 unsigned int a;
166
167 infile.read((char*)&(a),4);
168 cfg.length = a;
169 //std::cout << "a: " << a << std::endl;
170
171 for (unsigned int j = 0; j < cfg.length; j++)
172 {
173
175 infile.read((char*)(&name),64);
176 infile.read((char*)(&value),64);
177 key.name = name;
178 key.value = value;
179 cfg.keys.push_back(key);
180 }
181 set->configs.push_back(cfg);
182 }
183
184 for (unsigned int i = 0; i < _catalog->getYviews(); i++)
185 {
186 for (unsigned int j = 0; j < _catalog->getXviews(); j++)
187 {
188 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
189 _catalog->setFragmentIndexes(i,j,readUInt);
190
191 }
192
193 }
194 infile.seekg(256,std::ios::cur);
195 }
196 infile.close();
197 return true;
198}
#define SIZE_OF_CHAR
Definition: ProcessRawData.h:23
#define SIZE_OF_UNSIGNED_SHORT_INT
Definition: ProcessRawData.h:25
#define SIZE_OF_DOUBLE
Definition: ProcessRawData.h:27
#define SIZE_OF_INT
Definition: ProcessRawData.h:24
#define SIZE_OF_UNSIGNED_INT
Definition: ProcessRawData.h:26
void a()
Definition: check_aligned.C:59
void setNfragments(unsigned int n)
Definition: Catalog.h:33
SetupStringRepresentation * getSetup()
Definition: Catalog.h:48
void setXmin(double xMin)
Definition: Catalog.h:27
void initFragmentIndexes(unsigned int yviews, unsigned int xviews)
Definition: Catalog.h:23
bool setFragmentIndexes(unsigned int y, unsigned int x, unsigned int value)
Definition: Catalog.cpp:13
void setHeaderInfo(HeaderInfo headerInfo)
Definition: Catalog.cpp:4
void setYmax(double yMax)
Definition: Catalog.h:30
void setXstep(double xStep)
Definition: Catalog.h:31
void setXviews(unsigned int x)
Definition: Catalog.h:25
void setYviews(unsigned int y)
Definition: Catalog.h:26
void setYmin(double yMin)
Definition: Catalog.h:29
void setXmax(double xMax)
Definition: Catalog.h:28
void setYstep(double yStep)
Definition: Catalog.h:32
void initCatalog()
Definition: ProcessRawData.cpp:20
EdbScanSet * set
Definition: emtraceback.cpp:14
const char * name
Definition: merge_Energy_SytematicSources_Electron.C:24
Definition: Struct.h:54
std::string className
Definition: Struct.h:55
unsigned int length
Definition: Struct.h:58
std::vector< KeyStringRepresentation > keys
Definition: Struct.h:57
std::string name
Definition: Struct.h:56
Definition: Struct.h:20
Definition: Struct.h:48
std::string name
Definition: Struct.h:49
std::string value
Definition: Struct.h:50
Definition: Struct.h:62

◆ readFragment()

bool ProcessRawData::readFragment ( )
202{
203 initFragment();
204
205
206 View view;
207 std::vector<View> viewArr;
208 std::vector<Track> trackArr;
209
210
211 std::ifstream infile(_fragFileName.c_str(),std::ios::binary);
212 for(int i=0; i<5; i++) {
213 if (infile.fail()) {
214 infile.clear();
215 infile.open(_fragFileName.c_str(),std::ios::binary);
216 } else
217 break;
218 }
219 if (infile.fail())
220 {
221 std::cout << "Failed to open file: " << _fragFileName.c_str() << std::endl;
222 return false;
223 }
224 char infoType;
225 unsigned short headerFormat;
226 int codingMode;
227 unsigned int index, startView, nViews, fitCorrectionDataSize;
228
229 infile.read((char*)&infoType,SIZE_OF_CHAR);
230 infile.read((char*)&headerFormat,SIZE_OF_UNSIGNED_SHORT_INT);
231
232// if header && infotype da implementare
233 HeaderInfo id;
234 infile.read((char*)&id.part0,SIZE_OF_INT);
235 infile.read((char*)&id.part1,SIZE_OF_INT);
236 infile.read((char*)&id.part2,SIZE_OF_INT);
237 infile.read((char*)&id.part3,SIZE_OF_INT);
238 infile.read((char*)&index,SIZE_OF_UNSIGNED_INT);
239 infile.read((char*)&startView,SIZE_OF_UNSIGNED_INT);
240 infile.read((char*)&nViews,SIZE_OF_UNSIGNED_INT);
241 infile.read((char*)&fitCorrectionDataSize,SIZE_OF_UNSIGNED_INT);
242 infile.read((char*)&codingMode,SIZE_OF_INT);
243
244 _fragment->setId(id);
245 _fragment->setIndex(index);
246 _fragment->setStartView(startView);
247 _fragment->setViews(nViews);
248 _fragment->setFragmentCoding(codingMode);
249
250
251 if (!(codingMode == 0 || codingMode == 258)) // 0x0 == Normal, 0x102 == GrainSuppresion
252 {
253 std::cerr << "Unsupported fragment coding mode" << std::endl;
254 return -3;
255 }
256 infile.seekg(256,std::ios::cur);
257
258 if (headerFormat == 1795) // NormalDouble --> SCANGRID MODE
259 {
260 double readDouble;
261 int readInt;
262 char readChar;
263 for (unsigned int i = 0; i < nViews; i++)
264 {
265 view.setId(i);
266 Side topSide, bottomSide;
267 infile.read((char*)&readInt,SIZE_OF_INT);
268 view.setTileX(readInt);
269 infile.read((char*)&readInt,SIZE_OF_INT);
270 view.setTileY(readInt);
271 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
272 topSide.setStageFovPosX(readDouble);
273 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
274 bottomSide.setStageFovPosX(readDouble);
275 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
276 topSide.setStageFovPosY(readDouble);
277 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
278 bottomSide.setStageFovPosY(readDouble);
279 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
280 topSide.setMappedFovPosX(readDouble);
281 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
282 bottomSide.setMappedFovPosX(readDouble);
283 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
284 topSide.setMappedFovPosY(readDouble);
285 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
286 bottomSide.setMappedFovPosY(readDouble);
287
288 double mxx,mxy,myx,myy;
289 infile.read((char*)&mxx,SIZE_OF_DOUBLE);
290 infile.read((char*)&mxy,SIZE_OF_DOUBLE);
291 infile.read((char*)&myx,SIZE_OF_DOUBLE);
292 infile.read((char*)&myy,SIZE_OF_DOUBLE);
293 topSide.setM(mxx,mxy,myx,myy);
294 infile.read((char*)&mxx,SIZE_OF_DOUBLE);
295 infile.read((char*)&mxy,SIZE_OF_DOUBLE);
296 infile.read((char*)&myx,SIZE_OF_DOUBLE);
297 infile.read((char*)&myy,SIZE_OF_DOUBLE);
298 bottomSide.setM(mxx,mxy,myx,myy);
299 infile.read((char*)&readInt,SIZE_OF_INT);
300 topSide.setLayers(readInt);
301 infile.read((char*)&readInt,SIZE_OF_INT);
302 bottomSide.setLayers(readInt);
303 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
304 topSide.setTopZ(readDouble);
305 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
306 topSide.setBottomZ(readDouble);
307 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
308 bottomSide.setTopZ(readDouble);
309 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
310 bottomSide.setBottomZ(readDouble);
311
312 infile.read((char*)&readChar,SIZE_OF_CHAR);
313 topSide.setFlag(readChar);
314 infile.read((char*)&readChar,SIZE_OF_CHAR);
315 bottomSide.setFlag(readChar);
316
317 infile.read((char*)&readInt,SIZE_OF_INT);
318 topSide.setTracks(readInt);
319 infile.read((char*)&readInt,SIZE_OF_INT);
320 bottomSide.setTracks(readInt);
321
322 view.setTopSide(topSide);
323 view.setBottomSide(bottomSide);
324 viewArr.push_back(view);
325 }
326 for (unsigned int i = 0; i < nViews; i++)
327 {
328
329 for (int j = 0; j < viewArr.at(i).getTopSide()->getLayers(); j++)
330 {
331 unsigned int grains;
332 double z;
333 if(headerFormat == 1794 || headerFormat == 1795)
334 {
335 infile.read((char*)&grains,SIZE_OF_UNSIGNED_INT);
336 }
337 else
338 grains = 0;
339 infile.read((char*)&z,SIZE_OF_DOUBLE);
340 viewArr.at(i).getTopSide()->addLayer(grains,z);
341
342 }
343
344 for (int j = 0; j < viewArr.at(i).getBottomSide()->getLayers(); j++)
345 {
346
347 unsigned int grains;
348 double z;
349 if(headerFormat == 1794 || headerFormat == 1795)
350 {
351 infile.read((char*)&grains,SIZE_OF_UNSIGNED_INT);
352 }
353 else
354 grains = 0;
355 infile.read((char*)&z,SIZE_OF_DOUBLE);
356 viewArr.at(i).getBottomSide()->addLayer(grains,z);
357
358 }
359
360 }
361 for (unsigned int i = 0; i < nViews; i++)
362 {
363 Track tr;
364 unsigned int readUInt;
365 for (int j = 0; j < viewArr.at(i).getTopSide()->getTracks(); j++)
366 {
367
368 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
369 tr.setAreaSum(readUInt);
370 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
371 tr.setCount(static_cast<short>(readUInt));
372 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
373 tr.setX(readDouble);
374 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
375 tr.setY(readDouble);
376 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
377 tr.setZ(readDouble);
378 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
379 tr.setSX(readDouble);
380 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
381 tr.setSY(readDouble);
382 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
383 tr.setSZ(readDouble);
384 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
385 tr.setSigma(readDouble);
386 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
387 tr.setTopZ(readDouble);
388 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
389 tr.setBottomZ(readDouble);
390 viewArr.at(i).getTopSide()->addTrack(tr);
391
392 }
393 for (int j = 0; j < viewArr.at(i).getBottomSide()->getTracks(); j++)
394 {
395 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
396 tr.setAreaSum(readUInt);
397 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
398 tr.setCount(static_cast<short>(readUInt));
399 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
400 tr.setX(readDouble);
401 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
402 tr.setY(readDouble);
403 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
404 tr.setZ(readDouble);
405 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
406 tr.setSX(readDouble);
407 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
408 tr.setSY(readDouble);
409 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
410 tr.setSZ(readDouble);
411 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
412 tr.setSigma(readDouble);
413 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
414 tr.setTopZ(readDouble);
415 infile.read((char*)&readDouble,SIZE_OF_DOUBLE);
416 tr.setBottomZ(readDouble);
417 viewArr.at(i).getBottomSide()->addTrack(tr);
418 }
419 }
420 if (codingMode == 0)
421 {
422
423 for (unsigned int i = 0; i < nViews; i++)
424 {
425 for (int j = 0; j < viewArr.at(i).getTopSide()->getTracks(); j++)
426 {
427 Grain gr;
428 Track *tr = viewArr.at(i).getTopSide()->getTrackAt(j);
429 for (int k = 0; k < tr->getCount(); k++)
430 {
431 if (headerFormat == 1795)
432 {
433 unsigned int readUInt;
434 infile.read((char*)&readUInt,4);
435 gr.area = readUInt;
436 }
437 else
438 gr.area = 0;
439 infile.read((char*)&readDouble,8);
440 gr.x = readDouble;
441 infile.read((char*)&readDouble,8);
442 gr.y = readDouble;
443 infile.read((char*)&readDouble,8);
444 gr.z = readDouble;
445 tr->addGrain(gr);
446 }
447 if (_filterTracks)
448 tr->evaluateEstimators();
449 }
450 for (int j = 0; j < viewArr.at(i).getBottomSide()->getTracks(); j++)
451 {
452 Grain gr;
453 Track *tr = viewArr.at(i).getBottomSide()->getTrackAt(j);
454 for (int k = 0; k < tr->getCount(); k++)
455 {
456 if (headerFormat == 1795)
457 {
458 unsigned int readUInt;
459 infile.read((char*)&readUInt,4);
460 gr.area = readUInt;
461 }
462 else
463 gr.area = 0;
464 infile.read((char*)&readDouble,8);
465 gr.x = readDouble;
466 infile.read((char*)&readDouble,8);
467 gr.y = readDouble;
468 infile.read((char*)&readDouble,8);
469 gr.z = readDouble;
470 tr->addGrain(gr);
471 }
472 if (_filterTracks)
473 tr->evaluateEstimators();
474 }
475 }
476 }
477 }
478 else
479 {
480
481
482 float readFloat;
483 int readInt;
484
485
486
487 for (unsigned int i = 0; i < nViews; i++)
488 {
489 view.setId(i);
490 Side topSide, bottomSide;
491 infile.read((char*)&readInt,SIZE_OF_INT);
492 view.setTileX(readInt);
493 infile.read((char*)&readInt,SIZE_OF_INT);
494 view.setTileY(readInt);
495
496
497 infile.read((char*)&readFloat,4);
498 topSide.setStageFovPosX(readFloat);
499 infile.read((char*)&readFloat,4);
500 bottomSide.setStageFovPosX(readFloat);
501 infile.read((char*)&readFloat,4);
502 topSide.setStageFovPosY(readFloat);
503 infile.read((char*)&readFloat,4);
504 bottomSide.setStageFovPosY(readFloat);
505 infile.read((char*)&readFloat,4);
506 topSide.setMappedFovPosX(readFloat);
507 infile.read((char*)&readFloat,4);
508 bottomSide.setMappedFovPosX(readFloat);
509 infile.read((char*)&readFloat,4);
510 topSide.setMappedFovPosY(readFloat);
511 infile.read((char*)&readFloat,4);
512 bottomSide.setMappedFovPosY(readFloat);
513
514 float mxx4bytes,mxy4bytes,myx4bytes,myy4bytes;
515 infile.read((char*)&mxx4bytes,4);
516 infile.read((char*)&mxy4bytes,4);
517 infile.read((char*)&myx4bytes,4);
518 infile.read((char*)&myy4bytes,4);
519 topSide.setM(mxx4bytes,mxy4bytes,myx4bytes,myy4bytes);
520
521 infile.read((char*)&mxx4bytes,4);
522 infile.read((char*)&mxy4bytes,4);
523 infile.read((char*)&myx4bytes,4);
524 infile.read((char*)&myy4bytes,4);
525 bottomSide.setM(mxx4bytes,mxy4bytes,myx4bytes,myy4bytes);
526
527 infile.read((char*)&readInt,SIZE_OF_INT);
528 topSide.setLayers(readInt);
529 infile.read((char*)&readInt,SIZE_OF_INT);
530 bottomSide.setLayers(readInt);
531
532
533 infile.read((char*)&readFloat,4);
534 topSide.setTopZ(readFloat);
535 infile.read((char*)&readFloat,4);
536 topSide.setBottomZ(readFloat);
537 infile.read((char*)&readFloat,4);
538 bottomSide.setTopZ(readFloat);
539 infile.read((char*)&readFloat,4);
540 bottomSide.setBottomZ(readFloat);
541
542 unsigned int readUInt;
543 infile.read((char*)&readUInt,SIZE_OF_CHAR);
544 topSide.setFlag(readUInt);
545 infile.read((char*)&readUInt,SIZE_OF_CHAR);
546 bottomSide.setFlag(readUInt);
547
548 infile.read((char*)&readInt,SIZE_OF_INT);
549 topSide.setTracks(readInt);
550 infile.read((char*)&readInt,SIZE_OF_INT);
551 bottomSide.setTracks(readInt);
552
553 view.setTopSide(topSide);
554 view.setBottomSide(bottomSide);
555 viewArr.push_back(view);
556 }
557 for (unsigned int i = 0; i < nViews; i++)
558 {
559
560 for (int j = 0; j < viewArr.at(i).getTopSide()->getLayers(); j++)
561 {
562 unsigned int grains;
563 double z;
564 if(headerFormat == 1794 || headerFormat == 1795)
565 {
566 infile.read((char*)&grains,SIZE_OF_UNSIGNED_INT);
567 }
568 else
569 grains = 0;
570 infile.read((char*)&readFloat,4);
571 z = readFloat;
572 viewArr.at(i).getTopSide()->addLayer(grains,z);
573
574 }
575
576 for (int j = 0; j < viewArr.at(i).getBottomSide()->getLayers(); j++)
577 {
578
579 unsigned int grains;
580 double z;
581 if(headerFormat == 1794 || headerFormat == 1795)
582 {
583 infile.read((char*)&grains,SIZE_OF_UNSIGNED_INT);
584 }
585 else
586 grains = 0;
587 infile.read((char*)&readFloat,4);
588 z = readFloat;
589 viewArr.at(i).getBottomSide()->addLayer(grains,z);
590
591 }
592
593 }
594 for (unsigned int i = 0; i < nViews; i++)
595 {
596 Track tr;
597 unsigned int readUInt;
598 for (int j = 0; j < viewArr.at(i).getTopSide()->getTracks(); j++)
599 {
600
601 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
602 tr.setAreaSum(readUInt);
603 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
604 tr.setCount(static_cast<short>(readUInt));
605
606 infile.read((char*)&readFloat,4);
607 tr.setX(readFloat);
608 infile.read((char*)&readFloat,4);
609 tr.setY(readFloat);
610 infile.read((char*)&readFloat,4);
611 tr.setZ(readFloat);
612 infile.read((char*)&readFloat,4);
613 tr.setSX(readFloat);
614 infile.read((char*)&readFloat,4);
615 tr.setSY(readFloat);
616 infile.read((char*)&readFloat,4);
617 tr.setSZ(readFloat);
618 infile.read((char*)&readFloat,4);
619 tr.setSigma(readFloat);
620 infile.read((char*)&readFloat,4);
621 tr.setTopZ(readFloat);
622 infile.read((char*)&readFloat,4);
623 tr.setBottomZ(readFloat);
624 if(headerFormat == 1793) //old format
625 {
626 infile.read((char*)&readFloat,4);infile.read((char*)&readFloat,4);
627 infile.read((char*)&readFloat,4);infile.read((char*)&readFloat,4);
628 infile.read((char*)&readFloat,4);infile.read((char*)&readFloat,4);
629 infile.read((char*)&readFloat,SIZE_OF_UNSIGNED_INT);
630
631 }
632 viewArr.at(i).getTopSide()->addTrack(tr);
633
634
635 }
636 for (int j = 0; j < viewArr.at(i).getBottomSide()->getTracks(); j++)
637 {
638
639 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
640 tr.setAreaSum(readUInt);
641 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
642 tr.setCount(static_cast<short>(readUInt));
643
644 infile.read((char*)&readFloat,4);
645 tr.setX(readFloat);
646 infile.read((char*)&readFloat,4);
647 tr.setY(readFloat);
648 infile.read((char*)&readFloat,4);
649 tr.setZ(readFloat);
650 infile.read((char*)&readFloat,4);
651 tr.setSX(readFloat);
652 infile.read((char*)&readFloat,4);
653 tr.setSY(readFloat);
654 infile.read((char*)&readFloat,4);
655 tr.setSZ(readFloat);
656 infile.read((char*)&readFloat,4);
657 tr.setSigma(readFloat);
658 infile.read((char*)&readFloat,4);
659 tr.setTopZ(readFloat);
660 infile.read((char*)&readFloat,4);
661 tr.setBottomZ(readFloat);
662 if(headerFormat == 1793) //old format
663 {
664 infile.read((char*)&readFloat,4);infile.read((char*)&readFloat,4);
665 infile.read((char*)&readFloat,4);infile.read((char*)&readFloat,4);
666 infile.read((char*)&readFloat,4);infile.read((char*)&readFloat,4);
667 infile.read((char*)&readFloat,SIZE_OF_UNSIGNED_INT);
668
669 }
670 viewArr.at(i).getBottomSide()->addTrack(tr);
671
672 }
673 }
674 if (codingMode == 0)
675 {
676 for (unsigned int i = 0; i < nViews; i++)
677 {
678 for (int j = 0; j < viewArr.at(i).getTopSide()->getTracks(); j++)
679 {
680 Grain gr;
681 Track *tr = viewArr.at(i).getTopSide()->getTrackAt(j);
682 for (int k = 0; k < tr->getCount(); k++)
683 {
684 if (headerFormat == 1794)
685 {
686 unsigned int readUInt;
687 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
688 gr.area = readUInt;
689 }
690 else
691 gr.area = 0;
692 infile.read((char*)&readFloat,4);
693 gr.x = readFloat;
694 infile.read((char*)&readFloat,4);
695 gr.y = readFloat;
696 infile.read((char*)&readFloat,4);
697 gr.z = readFloat;
698 tr->addGrain(gr);
699 }
700 if (_filterTracks)
701 tr->evaluateEstimators();
702
703 }
704 for (int j = 0; j < viewArr.at(i).getBottomSide()->getTracks(); j++)
705 {
706 Grain gr;
707 Track *tr = viewArr.at(i).getBottomSide()->getTrackAt(j);
708 for (int k = 0; k < tr->getCount(); k++)
709 {
710 if (headerFormat == 1794)
711 {
712 unsigned int readUInt;
713 infile.read((char*)&readUInt,SIZE_OF_UNSIGNED_INT);
714 gr.area = readUInt;
715 }
716 else
717 gr.area = 0;
718 infile.read((char*)&readFloat,4);
719 gr.x = readFloat;
720 infile.read((char*)&readFloat,4);
721 gr.y = readFloat;
722 infile.read((char*)&readFloat,4);
723 gr.z = readFloat;
724 tr->addGrain(gr);
725 }
726 if (_filterTracks)
727 tr->evaluateEstimators();
728
729 }
730 }
731
732
733 }
734 }
735 _fragment->setViewsArray(viewArr);
736
737 infile.close();
738 return true;
739
740}
void setViewsArray(std::vector< View > vArr)
Definition: Fragment.cpp:13
void setFragmentCoding(int fragmentCoding)
Definition: Fragment.h:23
void setId(HeaderInfo id)
Definition: Fragment.cpp:22
void setStartView(unsigned int startView)
Definition: Fragment.h:25
void setViews(int nViews)
Definition: Fragment.h:26
void setIndex(unsigned int index)
Definition: Fragment.h:24
void initFragment()
Definition: ProcessRawData.cpp:26
void setLayers(int nLayers)
Definition: Side.h:46
void setBottomZ(double bottomZ)
Definition: Side.h:37
void setTopZ(double topZ)
Definition: Side.h:36
void setMappedFovPosY(double posy)
Definition: Side.h:42
void setTracks(int nTracks)
Definition: Side.h:44
void setM(double mxx, double mxy, double myx, double myy)
Definition: Side.cpp:45
void setFlag(int flag)
Definition: Side.h:45
void setMappedFovPosX(double posx)
Definition: Side.h:41
void setStageFovPosX(double posx)
Definition: Side.h:39
void setStageFovPosY(double posy)
Definition: Side.h:40
void setTopSide(Side side)
Definition: View.h:39
void setId(int id)
Definition: View.h:41
void setTileY(int y)
Definition: View.h:48
void setBottomSide(Side side)
Definition: View.h:40
void setTileX(int x)
Definition: View.h:47
grains()
Definition: grains.C:3
Definition: Struct.h:33
double y
Definition: Struct.h:36
double x
Definition: Struct.h:35
unsigned short area
Definition: Struct.h:34
double z
Definition: Struct.h:37

◆ setCatalogName()

void ProcessRawData::setCatalogName ( std::string  fileName)
inline
48{_catFileName = fileName;}

◆ setClOption()

void ProcessRawData::setClOption ( bool  noCl)
inline
51{_clusters = noCl;}

◆ setFilterTrackOption()

void ProcessRawData::setFilterTrackOption ( bool  filterTracks)
inline

◆ setFragmentName()

void ProcessRawData::setFragmentName ( std::string  fileName)
inline
49{_fragFileName = fileName;}

◆ setRootName()

void ProcessRawData::setRootName ( std::string  fileName)
inline
50{_outputRootFileName = fileName;}

Member Data Documentation

◆ _catalog

Catalog* ProcessRawData::_catalog
private

◆ _catFileName

std::string ProcessRawData::_catFileName
private

◆ _clusters

bool ProcessRawData::_clusters
private

◆ _filterTracks

bool ProcessRawData::_filterTracks
private

◆ _fragFileName

std::string ProcessRawData::_fragFileName
private

◆ _fragment

Fragment* ProcessRawData::_fragment
private

◆ _outputRootFileName

std::string ProcessRawData::_outputRootFileName
private

◆ _run

EdbRun* ProcessRawData::_run
private

The documentation for this class was generated from the following files: