File indexing completed on 2023-03-17 11:27:24
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <iostream>
0010 #include <iomanip>
0011 #include <map>
0012
0013
0014 Double_t tolerance = 0.0001;
0015
0016
0017
0018 std::map< std::string , Int_t > theNewMapNavTypeToDetId;
0019 std::map< std::string , Int_t > theReferenceMapNavTypeToDetId;
0020
0021
0022 std::map< std::string , Double_t > theNewMapNavTypeToGlobalPosition_X;
0023 std::map< std::string , Double_t > theNewMapNavTypeToGlobalPosition_Y;
0024 std::map< std::string , Double_t > theNewMapNavTypeToGlobalPosition_Z;
0025
0026 std::map< std::string , Double_t > theReferenceMapNavTypeToGlobalPosition_X;
0027 std::map< std::string , Double_t > theReferenceMapNavTypeToGlobalPosition_Y;
0028 std::map< std::string , Double_t > theReferenceMapNavTypeToGlobalPosition_Z;
0029
0030
0031
0032 TrackerNumberingComparison( TString newFileName , TString referenceFileName , TString outputFileName) {
0033
0034 std::ifstream theNewFile;
0035 theNewFile.open(newFileName);
0036 std::ifstream theReferenceFile;
0037 theReferenceFile.open(referenceFileName);
0038
0039 std::ofstream theOutputFile;
0040 theOutputFile.open(outputFileName);
0041 theOutputFile
0042 << std::setprecision(4)
0043 << std::fixed;
0044
0045
0046
0047 Int_t detid;
0048 detid = 0;
0049 std::string navType;
0050 Double_t x,y,z;
0051 x=y=z=0.0000;
0052
0053
0054 while(!theNewFile.eof()) {
0055
0056 theNewFile >> detid
0057 >> navType
0058 >> x >> y >> z;
0059
0060
0061
0062 theNewMapNavTypeToDetId[navType] = detid;
0063 theNewMapNavTypeToGlobalPosition_X[navType] = x;
0064 theNewMapNavTypeToGlobalPosition_Y[navType] = y;
0065 theNewMapNavTypeToGlobalPosition_Z[navType] = z;
0066
0067 }
0068
0069
0070
0071 while(!theReferenceFile.eof()) {
0072
0073 theReferenceFile >> detid
0074 >> navType
0075 >> x >> y >> z;
0076
0077
0078
0079 theReferenceMapNavTypeToDetId[navType] = detid;
0080 theReferenceMapNavTypeToGlobalPosition_X[navType] = x;
0081 theReferenceMapNavTypeToGlobalPosition_Y[navType] = y;
0082 theReferenceMapNavTypeToGlobalPosition_Z[navType] = z;
0083
0084 }
0085
0086
0087
0088
0089
0090
0091
0092
0093 if(theNewMapNavTypeToDetId.size() != theReferenceMapNavTypeToDetId.size()) {
0094 theOutputFile << "ERROR: The size of the two detid-navtype maps is different" << std::endl;
0095 theOutputFile << " Reference = " << theReferenceMapNavTypeToDetId.size() << std::endl;
0096 theOutputFile << " New = " << theNewMapNavTypeToDetId.size() << std::endl;
0097 }
0098 if(theNewMapNavTypeToGlobalPosition_X.size() != theReferenceMapNavTypeToGlobalPosition_X.size()) {
0099 theOutputFile << "ERROR: The size of the two X-navtype maps is different" << std::endl;
0100 theOutputFile << " Reference = " << theReferenceMapNavTypeToGlobalPosition_X.size() << std::endl;
0101 theOutputFile << " New = " << theNewMapNavTypeToGlobalPosition_X.size() << std::endl;
0102 }
0103 if(theNewMapNavTypeToGlobalPosition_Y.size() != theReferenceMapNavTypeToGlobalPosition_Y.size()) {
0104 theOutputFile << "ERROR: The size of the two Y-navtype maps is different" << std::endl;
0105 theOutputFile << " Reference = " << theReferenceMapNavTypeToGlobalPosition_Y.size() << std::endl;
0106 theOutputFile << " New = " << theNewMapNavTypeToGlobalPosition_Y.size() << std::endl;
0107 }
0108 if(theNewMapNavTypeToGlobalPosition_Z.size() != theReferenceMapNavTypeToGlobalPosition_Z.size()) {
0109 theOutputFile << "ERROR: The size of the two Z-navtype maps is different" << std::endl;
0110 theOutputFile << " Reference = " << theReferenceMapNavTypeToGlobalPosition_Z.size() << std::endl;
0111 theOutputFile << " New = " << theNewMapNavTypeToGlobalPosition_Z.size() << std::endl;
0112 }
0113
0114 for( std::map< std::string , Int_t >::iterator iMap = theReferenceMapNavTypeToDetId.begin();
0115 iMap != theReferenceMapNavTypeToDetId.end(); iMap++ ) {
0116
0117
0118 Int_t referenceDetId = (*iMap).second;
0119 std::string navType = (*iMap).first;
0120 Int_t newDetId = theNewMapNavTypeToDetId[navType];
0121 if( referenceDetId != newDetId ) {
0122 theOutputFile << "ERROR: The detid's associated to the same navtype do not correspond" << std::endl;
0123 theOutputFile << " reference: " << " detid " << referenceDetId << " navtype " << navType << std::endl;
0124 theOutputFile << " new: " << " detid " << newDetId << " navtype " << navType << std::endl;
0125 }
0126 }
0127
0128
0129 for( std::map< std::string , Int_t >::iterator iMap = theReferenceMapNavTypeToDetId.begin();
0130 iMap != theReferenceMapNavTypeToDetId.end(); iMap++ ) {
0131
0132 std::string navType = (*iMap).first;
0133
0134 Double_t referenceX = theReferenceMapNavTypeToGlobalPosition_X[navType];
0135 Double_t referenceY = theReferenceMapNavTypeToGlobalPosition_Y[navType];
0136 Double_t referenceZ = theReferenceMapNavTypeToGlobalPosition_Z[navType];
0137 Double_t newX = theNewMapNavTypeToGlobalPosition_X[navType];
0138 Double_t newY = theNewMapNavTypeToGlobalPosition_Y[navType];
0139 Double_t newZ = theNewMapNavTypeToGlobalPosition_Z[navType];
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 if( fabs(referenceX-newX) > tolerance
0156 ||
0157 fabs(referenceY-newY) > tolerance
0158 ||
0159 fabs(referenceZ-newZ) > tolerance ) {
0160 theOutputFile << "ERROR: The positions associated to the same navtype do not correspond" << std::endl;
0161 theOutputFile
0162 << " reference: "
0163 << " x = " << referenceX
0164 << " y = " << referenceY
0165 << " z = " << referenceZ
0166 << " navtype " << navType
0167 << std::endl;
0168 theOutputFile
0169 << " new: "
0170 << " x = " << newX
0171 << " y = " << newY
0172 << " z = " << newZ
0173 << " navtype " << navType
0174 << std::endl;
0175 }
0176
0177 }
0178
0179 }